Click to See Complete Forum and Search --> : JavaScript List/Box Value Access


antosart
08-06-2003, 05:17 PM
Ello all,

Ok I've got a list/menu box that will have it's <option> tags populated dynamically via JSP from a database, allowing multiple selections.

I will also have a 2nd list/ menu box off to the right that is empty.

I want to click a button (preferably and image with the onClick="functionCall()") and then transfer the selected option information to the other list/ menu box and then remove the data from the first list/ menu box. (similar to DTP functionality...) basically transfering the data from one list to the other.

I'm pretty JS savvy but can't find any solid documentation on how to access the multiple values in a list/ menu box.

The best that I could find is the document.forms[0].elements[0].value

Can anyone help me out with this?
Much appreciated
-Antosart:)

Khalid Ali
08-06-2003, 05:36 PM
run a loop through the list box elements and then check for selected values....then you can put them in the second list box

antosart
08-06-2003, 05:53 PM
I understand this concept from a high level...
but how specifically do I detect and access the various selected values?

like this?

var count = 5;

for (i = 0; i < count; i++){
var element[i] = document.forms[i].elements[i].value[i];
}

That is about as far as I have gotten... do you have any code snippets? Not sure if I'm even approaching this right at all.
Thanks again,
Antosart

Khalid Ali
08-06-2003, 05:58 PM
I thinklink below will help you.
Its rather advance code,you will get the idea how to get multiple selected values.

http://68.145.35.86/skills/javascripts/MakeListboxMultipleSelect.html