Click here to Skip to main content
15,898,792 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please see http://forums.asp.net/p/983898/1264650.aspx#1264650
There is a solution posted at Apr 21, 2006 07:15 PM
I'd like to use this code except that listbox1 needs to be a dropdown box. How do I adapt the code?
To get the code working change
var optionsList = ';
to
var optionsList = '';
Posted
Updated 22-Jan-14 2:05am
v2

1 solution

Please post your question here, if you want to be answered here. Either ask there for more help, or explain here what you've done and where you're stuck, without sending us to another forum.
 
Share this answer
 
Comments
Alhal 23-Jan-14 11:37am    
This function is OK. However when I pass the name of the listbox to this function it stops working.
For example it will say listBox2.options.length is not recognised.

function ListBox2_onchange()
{
var DropDownList1 = document.getElementById('DropDownList1');
var listBox2 = document.getElementById('ListBox2');

for (var i=0; i<listBox2.options.length; i++)
{
if ( listBox2.options[i].selected )
{
var newOption = window.document.createElement('OPTION');
newOption.text = listBox2.options[i].text;
newOption.value = listBox2.options[i].value;

DropDownList1.options.add(newOption);
listBox2.options.remove(i);
}
}

persistOptionsList();
}
Christian Graus 23-Jan-14 16:23pm    
cmbfiletypecode.options is null. So you need to set a break point in Chrome and work out why that is, and fix your code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900