[Javascript] Set all list box drop downs to a single value
Mike Dougherty
mdougherty at pbp.com
Mon Jul 21 07:24:49 CDT 2003
If you DON'T know the names, and you really do want ALL checkboxes do
something like:
var loCollection = document.getElementsByTagName("input")
for (loItem in loCollection) {
if ( loItem.type == "checkbox" ) {
loItem.selectedIndex = 3; /* if there aren't 4 items, the first
option is selected */
}
}
Note: I haven't tested this code, so your mileage my vary...
-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of David Yee
Sent: Friday, July 18, 2003 6:26 PM
To: '[JavaScript List]'
Subject: RE: [Javascript] Set all list box drop downs to a single value
*This message was transferred with a trial version of CommuniGate(tm)
Pro*
Thanks Peter- that should work.
-----Original Message-----
From: Peter Brunone [mailto:peter at brunone.com]
Sent: Friday, July 18, 2003 1:19 PM
To: '[JavaScript List]'
Subject: RE: [Javascript] Set all list box drop downs to a single value
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
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list