Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change select box based on another select box

Status
Not open for further replies.

rundmc

Programmer
Jan 16, 2003
15
US
Hi
I have several select boxes all of the same name with the same options. if an option is selected in any one of the select boxes, then the same option is also selected in all the other boxes.

how would I do this??

Any help is greatly appreciated!



 
Put this code between your [tt]<head></head>[/tt] tags:

Code:
function makeAllSame(si) {
    var s = document.forms['the_form'].elements['the_select'];
	for (var i = 0; i < s.length; i++)
	    s[i].selectedIndex = si;
}

This code assumes your form name is "the_form" and your select box names are "the_select". Then, put this in each [tt]<select>[/tt] tag:

Code:
<select ... onchange="makeAllSame(this.selectedIndex);">

*cLFlaVA
----------------------------
Breaking the habit...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top