Iterating comboboxes (<SELECT>) using javascript

Discussion in 'Javascript' started by Melbfella, Oct 15, 2007.

  1. Melbfella

    Melbfella Guest

    G'day all

    I apologise in advance for the newbiness of this question, but the
    answer has eluded me for 3 days now - hopefully one of you gurus out
    there might be able to help .......


    I have a page that dynamically draws checkboxes with a combo. I'm
    then
    attempting to use the following code to iterate through each combo
    box
    and change the value to match the text box.


    Here's the code that calls the functions, and the
    functions themselves......


    **Code that fires the event
    <input class="ctlstandard" type="text" name="txtSeats" id="txtSeats"
    onblur="setOptionCombos);"/>&nbsp;<font color="<
    %=session("BrandTextColour")%>">*</font></td>


    **The function


    function setOptionCombos(){
    var lSeats=frmMain.txtSeats.value;
    for (i=0;i<frmMain.cboTourOptionQty.length;i++){
    frmMain.cboTourOptionQty.selectedIndex=lSeats-1;
    }

    }


    This works if there are two combos on the screen, but does not when
    there's only one. It seems the event doesn't, although all get
    changed
    quite happily when there's 2 or more.

    If there are 2 combos, the expression
    frmMain.cboTourOptionQty.length=2


    If there's only 1 combo, the expression
    frmMain.cboTourOptionQty.length=100 (the number of options in the
    list)


    Any help or thoughts would be greatly appreciated :)


    Cheers,


    Doug.
     
    Melbfella, Oct 15, 2007
    #1
    1. Advertisements

  2. Melbfella

    David Mark Guest

    David Mark, Oct 15, 2007
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith Henderson

    for each for comboboxes on page

    Keith Henderson, Sep 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    463
    Scott Allen
    Sep 24, 2004
  2. Lucas Tam

    Displaying Chinese in ComboBoxes

    Lucas Tam, Oct 26, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    458
    Lucas Tam
    Oct 26, 2004
  3. Craig G
    Replies:
    3
    Views:
    726
    Ken Cox [Microsoft MVP]
    Feb 18, 2005
  4. Craig G

    BorderStyle on ComboBoxes

    Craig G, Feb 22, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    420
    Craig G
    Feb 22, 2005
  5. Craig G

    Searchable ComboBoxes

    Craig G, Mar 23, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    427
    Teemu Keiski
    Mar 23, 2005
  6. carl
    Replies:
    5
    Views:
    3,075
    James Kanze
    Nov 25, 2009
  7. palmiere
    Replies:
    1
    Views:
    666
    Erwin Moller
    Feb 9, 2004
  8. Melbfella
    Replies:
    0
    Views:
    118
    Melbfella
    Oct 15, 2007
Loading...