Phil Powell said:
I have a form with two single-choice dropdowns. Upon doing an onChange
event on either one of them, I want to check to see if the other dropdown
has also been selected. How would I do that, considering that this.parent
causes an error "null or not an object"?
The "parent" attribute is an attribute of windows.
Form elements have an attribute named "form", which is a reference
to the containing form.
<html>
<head>
<script type="text/javascript">
function seeIfBothChosen(f){
if(f.select1.selectedIndex && f.select2.selectedIndex){
alert(f.select1.options[f.select1.selectedIndex].text + " / " +
f.select2.options[f.select2.selectedIndex].text);
}
}
</script>
</head>
<body>
<form>
<select name="select1" onchange="seeIfBothChosen(this.form)">
<option>--Choose--</option>
<option>alpha</option>
<option>beta</option>
</select>
<select name="select2" onchange="seeIfBothChosen(this.form)">
<option>--Choose--</option>
<option>gamma</option>
<option>delta</option>
</select>
</form>
</body>
</html>