Iterating comboboxes (<SELECT>) using javascript

M

Melbfella

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top