[Javascript] Set all list box drop downs to a single value
Peter Brunone
peter at brunone.com
Fri Jul 18 15:19:08 CDT 2003
David,
If you know the names of the checkboxes (BTW, it's a good idea
not to start object names with integers, because it can confuse the
scripting engine), you can just go through a loop like this:
for (i=10001;i<=10003;i++) {
var newCheckBox = eval("document.formName." + i + "[status]");
// selectedIndex is the index of the current option (in a
zero-based array)
newCheckBox.selectedIndex = 3;
}
This should get you started; let us know if you have more
questions.
Cheers,
Peter
-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of David Yee
Hi- how can I set all the drop downs on my form to a single value with
the click of a button? I've seen ways to do it with checkboxes but I'm
not sure how to do it with drop downs. The names of the select box
variables are in a number sequence e.g.
<select name=10001[status]>
<option value=N>NOT_STARTED
<option value=I>IN-PROGRESS
<option value=C>COMPLETE
</select>
<select name=10002[status]>
<option value=N>NOT_STARTED
<option value=I>IN-PROGRESS
<option value=C>COMPLETE
</select>
<select name=10003[status]>
<option value=N>NOT_STARTED
<option value=I>IN-PROGRESS
<option value=C>COMPLETE
</select>
Thanks for any help!
David
More information about the Javascript
mailing list