Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    add to a listbox with javascript, see changes in postback

    I add to an asp:listbox using javascript:
    Code:
    //*****
    //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:
    Code:
    'print out how many items
    Response.Write(lstWizardStudentsChosen.Items.Count & "<br>")
    'and their text
    For i = 0 to lstWizardStudentsChosen.Items.Count -1
        Response.Write(lstWizardStudentsChosen.Items(i))
    Next
    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?

  • #2
    New to the CF scene
    Join Date
    Nov 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question listbox and javascritp

    Hi,

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

    Thanks so much,
    TL


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •