var labelText = document.getElementById('Label1').innerText'
var msg= document.getElementById('TextBox3').value;
var optionText = labelText + ' ' + msg;
var optionValue = msg;
var objOption = new Option(optionText, optionValue)
var listObject = document.getElementById('ListBox1');
var itemPosition = listObject.length;
listObject.options[itemPosition] = objOption;
Now there are a few problems with this code. First off you are referencing your Server controls with the value that you are supplying for the ID property. The problem here is that your controls may not be named this on the clientside when they are ultimately emitted and sent to the browser. For example, a textbox in a user control may actually wind up with an ID of: UserControl_TextBox1! To circumvent this problem you should get used to using syntax such as:
var listObject = document.getElementById('<%=ListBox1.ClientID%>');
var textBox = document.getElementById('textHide');
var listObject = document.getElementById('test');
textBox.value = '';
for(i=0; i <= listObject.options.length - 1; i++)
textBox.value = textBox.value + listObject.options[i].value + ', ' ;
-I tested all code in IE 7.0 without a problem.
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click
on their post!
"Easy is the path to wisdom for those not blinded by themselves."