Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing values from one list box to another

Status
Not open for further replies.

Lbob

Programmer
May 23, 2003
157
0
0
GB
Hi

I want to be able to select a Client from my All Clients listbox and show it in a Selected Clients Listbox. Does anyone know how to do this?

Thanks
Lbob
 
Ok

I have 2 list boxes on the page, one which is filled with all Clients, the other I want to fill when the user double clicks on a client in the all clients list. It should then disappear from the All Clients list box and appear in the Selected Clients listbox.

Any ideas?
Thanks
Lbob
 
All you have to do is have a javascript function accepting the 2 select boxes as parameters. Loop through the first one and if the current item is selected, add it to the second. Set the current item of the first list box value to null and decrement the current counter after adding the current item's value and text to the second select box at the index of the second one's current length.

something like this...


for(var i=0;i<obj1.length;i++)
{
if(obj1.options.selected)
{
obj2.options[obj2.length]=new Option(obj1.options.text,obj1.options.value);
obj1.options=null;
i--;
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top