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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation between 2 select dropdowns

Status
Not open for further replies.

bamboo

Programmer
Aug 22, 2001
89
US
I have two select dropdowns in one form. If one selectedIndex == a certain number I set the other selectedIndex appropriately. I have the following js working fine:

<script language="javascript">
function fnCheckCategory(form)
{

var passed = true;

if (form.websiteid != null)
if (form.ReqTypeFilter.selectedIndex != 7) {form.websiteid.selectedIndex = 0;};
passed = true;
}
</script>

I now need to add a condition if form.ReqTypeFilter.selectedIndex == 7, then set the form.websiteid.selectedIndex = 1. I thought it would be easy enough to add an else if statement, but everything I've tried thus far does not work.
 
I figured it out. Duh . . .

<script language="javascript">
function fnCheckCategory(form)
{

var passed = true;

if (form.websiteid != null)
if (form.ReqTypeFilter.selectedIndex != 7) {form.websiteid.selectedIndex = 0;};
else {form.websiteid.selectedIndex = 1;};
passed = true;
}
</script>
 

One question, though... Why are you setting "passed" to true twice? Surely one of the two lines that does this is redundant?

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top