Quote:
Originally Posted by vinamr
Hi Philip,
Apologize for the late reply as I was travelling and thanks much for your code. It did work.
However a minor tweak hoping you can help me.
1) When Language dropdown is selected a member can only select Arts-2 class from the Arts dropdown (but not Arts-1 because all language classes and Arts-1 class are offerred at the same time 10:00 - 11:30). Hence the clash.
2) Instead of a message I want some sort of popup alert informing the member that he/she cannot select arts when language is selected.
Thanks for your help in advance.
Regards
Vinny
|
You did not ask for that! It just makes it harder for everyone if you change your requirements.
Code:
<html>
<head>
<body>
<select id = "childlang" onchange = "checkit()">
<option value = "">Select a language</option>
<option value = "English">English</option>
<option value = "French">French</option>
<option value = "Chinese">Chinese</option>
</select>
<select id = "childarts" onchange = "checkit()">
<option value = "">Or select an arts subject</option>
<option value = "Arts-1">Arts-1</option>
<option value = "Arts-2">Arts-2</option>
</select>
<span id = "message" style = "color:red";></span>
<script type = "text/javascript">
function checkit() {
var msg = " You may not select a language class if you have selected an Arts-1 class or vice-versa. Please choose again.";
document.getElementById("message").innerHTML = "";
var val1 = document.getElementById("childlang").value;
var val2 = document.getElementById("childarts").value;
if (val1 != "" && val2 =="Arts-1") {
document.getElementById("message").innerHTML = msg;
document.getElementById("childlang").selectedIndex = 0;
document.getElementById("childarts").selectedIndex = 0;
return false;
}
}
</script>
</body>
</html>
Pop-ups (alerts) are deprecated and obsolete. They may be blocked by the browser. The proper way to display a message to the user is as I have indicated.