View Full Version : add to a listbox with javascript, see changes in postback

02-18-2003, 02:56 AM
I add to an asp:listbox using javascript:

//all this does is adds the selected item(s) from one listbox to another
var f = document.theform;
var chosen = f.elements['ecContent_ecModuleTeacher_lstWizardStudentsChosen'];
var available = f.elements['ecContent_ecModuleTeacher_lstWizardStudentsAvailable'];
var len=available.options.length
for (var loop=0; loop<len; loop++)
if (available.options[loop].selected==true)
var option = available.options[loop];
var opt = new Option( option.text, option.value );
chosen.options[chosen.length] = opt;

Then when I click an asp:Button, I want to see how many items were added to the listbox, and what their texts are:

'print out how many items
Response.Write(lstWizardStudentsChosen.Items.Count & "<br>")
'and their text
For i = 0 to lstWizardStudentsChosen.Items.Count -1

The first response write above that is supposed to print out how many items are in the listbox prints out 0. Am I missing something? And for those of you who like to just read the question, and not the fluff:
So how can I, during a postback, see what changes were done to an asp:Listbox with javascript?

Thuy Le
11-04-2004, 11:32 PM

Did you get the solution for this problem? Please post the code if you did.

Thanks so much,