473,594 Members | 2,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

is it possible to get options from list without selection

106 New Member
i have a JS function which adds items to a list when the user clicks on a button ADD ITEM now i need to get all the items he added in the list without selecting them !! is that possible ?
i need to insert those items in the DB
any ideas ?
Nov 12 '08 #1
7 1731
gits
5,390 Recognized Expert Moderator Expert
of course ... you just need to loop over the options that a select-node contains. could you post an example and tell what you want to retrieve the values or the 'description' of the items ... or both? how do you want to transfer the data?

kind regards
Nov 12 '08 #2
jessy
106 New Member
Well, this is my pretty simple JS function
Expand|Select|Wrap|Line Numbers
  1. function AddItem()
  2.     {   var opt = document.getElementById("List1");
  3.         var value=opt.options[opt.selectedIndex].text;
  4.         var newItem=document.createElement("option");
  5.         newItem.text=value;
  6.         document.getElementById("List2").options.add(newItem);
  7.   }
  8.  
and this is my List 2 (destination list) ==>
Expand|Select|Wrap|Line Numbers
  1. <select size="6" id="List2" name="list2[]" ></select>
these data are sent to DB.php which is supposed to take the posted data into the DB and thats the page at which i should loop through the options as u said but dont know how ??
Nov 12 '08 #3
gits
5,390 Recognized Expert Moderator Expert
not exactly what i meant ... you need to loop at the client and add the options to the postdata onsubmit of your form or do you do an ajax-call?
Nov 12 '08 #4
jessy
106 New Member
i dont know if i get you But im doing this through onchange event for the select which submits the form
Expand|Select|Wrap|Line Numbers
  1.  select name="uniforms" onChange=this.form.submit();
and upon selection the user is presented with two list boxes with add to list and remove from list arrows ..so when he clicks on add to list(list2) and chooses all he wants from list1 to be added to list 2 he clicks on ADD button this button moves to the DB.php page which i was hoping to get the options in the list 2 WITHOUT selection ( just get all the items in there )
Nov 12 '08 #5
gits
5,390 Recognized Expert Moderator Expert
so as i understand ... you have a second submit then? and this form with the two lists just need to take care of your problem? while adding and deleting you have two options. you could use the iterate method to get all options in the list or you may have a hidden field that contains them ... just update this while adding deleting items ... the other option could always do this on submit of the second form.

kind regards
Nov 12 '08 #6
jessy
106 New Member
Can u plz post some piece of code for any of the options u specified
Nov 12 '08 #7
gits
5,390 Recognized Expert Moderator Expert
ok ... here is an example for how to get all option-values of a list 'foo' onclick of a button:

[HTML]<html>
<script type="text/javascript">
function get_options() {
var n = document.getEle mentById('foo') ;
var l = [];

for (var i = 0, o; o = n.childNodes[i]; i++) {
if (/^option$/i.test(o.tagNam e)) {
l.push(o.value) ;
}
}

alert(l);
}
</script>
<body>
<select id="foo">
<option value="foo1">fo o1</option>
<option value="foo2">fo o2</option>
<option value="foo3">fo o3</option>
<option value="foo4">fo o4</option>
<option value="foo5">fo o5</option>
</select>
<input type="button" onclick="get_op tions()" value="get options"/>
</body>
</html>
[/HTML]
now you just need to do anything you want with those values.

kind regards
Nov 12 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
6952
by: glin | last post by:
Hi there, does anyone know how to use smarty to generate a selection list without PHP assigning a array? eg. a list for selection minutes, but without php to assign a 1~60 array into smarty. Thanks in advance.
7
2309
by: jason | last post by:
Is there a way - possibly a disconnected rs? - to update the contents of an existing pulldown on a page without having to re-submit the page for the user to see the pulldown populated with an additional value? I realise there are javascript possibilities (and I am still searching for a usable one) but I thought perhaps it may be possible to allow a user to add a new entry to a drop down box that had been dynamically populated from an...
12
6528
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the courses to pass the correct option value and then be displayed at the following URL: http://www.dslextreme.com/users/kevinlyons/selectResults.html I am passing countries, products, and courses. The first two display
7
4261
by: John C | last post by:
I am working with an HTML-based form that uses a select element that requires about 200 options. Is there a way that I can load, or select one of these options from a file, rather than hardcode them into the select element? Thanks
3
12037
by: RRoberto | last post by:
Goodmorning, Is it possible to edit a combobox like a textbox? I will appreciate any suggestion . Thank You Roberto
10
2284
by: JL | last post by:
Does anyone have any ideas on this please? I don't know how to evaluate the no-blank selections against each other from a form as follows: . I have a form with 6 dropdown fields, each containing a selection of 30 options (the 30 options are the same for each dropdown list). The user needs to select 'one of the 30 options' from each dropdown selection, but each option they select must be unique (no duplicate selections) or it must be...
15
15437
by: TJ Walls | last post by:
Hello All, Is it possible to create a <select> element with no selected options? I have tried setting the selectedIndex attribute to -1, but as far as I can tell this only works for <select multiple> elements. Am I missing something obvious? Sincerely, TJ Walls
4
5098
by: Colleyville Alan | last post by:
I am trying to use a list box to allow users to select items, the results are queried based on the selection and written to a spreadsheet. If the item already exists on their current spreadsheet, I'd like to indicate that so that they do not choose the same item a second time. Right now, I have the listbox show those items that are already on the spreadsheet using the selection property (selected = true). But that actually increases...
5
4566
by: srampally | last post by:
I need the capabilty to hide/show a selection list, just the way its done at http://www.lufthansa.com (place the cursor over "Group Companies"). However, I am looking for a javascript that is much simpler. Here is what I have until now. Problems with my code: 1. The selection list becomes invisible when I try to select an option (in Firefox). 2. The selection list stays visible when I just place the cursor over selection list and move...
2
1084
by: jessy | last post by:
My Problem is that i have a list which contains some items added by the user from another list now i need this second list to be added to the Database but without the user selecting all the items ... how can this be done if its possible ? coz i only now how to add selected items : bytheway the list is Multiple list
0
7947
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8255
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8010
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5413
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3868
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3903
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1486
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.