473,226 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

is it possible to get options from list without selection

106 100+
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 1713
5,390 Expert Mod 4TB
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
106 100+
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.   }
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
5,390 Expert Mod 4TB
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
106 100+
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
5,390 Expert Mod 4TB
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
106 100+
Can u plz post some piece of code for any of the options u specified
Nov 12 '08 #7
5,390 Expert Mod 4TB
ok ... here is an example for how to get all option-values of a list 'foo' onclick of a button:

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

for (var i = 0, o; o = n.childNodes[i]; i++) {
if (/^option$/i.test(o.tagName)) {

<select id="foo">
<option value="foo1">foo1</option>
<option value="foo2">foo2</option>
<option value="foo3">foo3</option>
<option value="foo4">foo4</option>
<option value="foo5">foo5</option>
<input type="button" onclick="get_options()" value="get options"/>
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

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. ...
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...
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...
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...
by: RRoberto | last post by:
Goodmorning, Is it possible to edit a combobox like a textbox? I will appreciate any suggestion . Thank You Roberto
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...
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...
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,...
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...
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 ......
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.