How to add an item to asp:listbox in clientside?
ASP.NET
2
Posts
2
Posters
0
Views
1
Watching
-
Hi, How could I add an item to asp:listbox in clientside using javascript. Thanks in advance.
Be simple and Be sample.
var listBox = document.getElementById( '<%= ListBox1.ClientID %>' ); alert(listBox.length); listBox.options[0] = new Option("Hello"); alert(listBox.length);
Like this....... Note that there is no ADD item as such that work cross browser, you have to get the number of items currently there and then add new ones by changing the index (the options[indexnumber] above). Mark.