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!

Drop Down Menus/If...Else.../OnChange 1

Status
Not open for further replies.

booboo0912

Programmer
Jul 31, 2002
75
US
Hello! This is probably a simple question for some, but I'm a newbie...enuff said? :)

I have two drop-down menus: Day1 and Day2
In each menu, I have the following values: Track1, Track2 Track3

The user can select Track1 for the first menu, and Track2 for the second menu, or vice versa, but if either menu has a value=Track3, the other menu value MUST be Track3 as well (I was trying to populate the other menu based on the value of the first, if the value was Track3, but got stuck in an if...else loop b/c I wasn't able to re-select a different value).

I need for the users to be able to make their selections, but also change their selections if needed.

Is this one long If...else statement, or is there a better way?
Thanks in advance!
 
This should work fine:

<SCRIPT>
<!--
function check(whi){
if(whi=='d1'){
if(document.form1.Day1.selectedIndex==3)
document.form1.Day2.selectedIndex=3;
else if(document.form1.Day2.selectedIndex==3)
document.form1.Day2.selectedIndex=0;
} else if(whi=='d2'){
if(document.form1.Day2.selectedIndex==3)
document.form1.Day1.selectedIndex=3;
else if(document.form1.Day1.selectedIndex==3)
document.form1.Day1.selectedIndex=0;
}
}
//-->
</SCRIPT>

<form name=&quot;form1&quot;>
<SELECT onChange=&quot;check('d1')&quot; name=&quot;Day1&quot;>
<option SELECTED>--select an option...--</option>
<option>Track 1</option>
<option>Track 2</option>
<option>Track 3</option>
</SELECT>

<SELECT onChange=&quot;check('d2')&quot; name=&quot;Day2&quot;>
<option SELECTED>--select an option...--</option>
<option>Track 1</option>
<option>Track 2</option>
<option>Track 3</option>
</SELECT>
</form>

Rick if(($question==&quot;has been bugging me&quot;
AND $answer==&quot;fixed the problem&quot;) OR $answer==&quot;really good post&quot;){
print(&quot;Star&quot;);
}else{
print(&quot;Thanks.&quot;);
}
 
THANK YOU THANK YOU THANK YOU, RICK!
That worked perfectly...thanks for teaching me a thing or two also! Have a great day!
T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top