Forum Moderators: open
Hi I have an online form where users can select what options they would like of a "menu". For example an option asks would they like 2, or 3 courses? Then I have a bank of 5 radio buttons with different options for the first course, a bank of 5 for the second course and the same for the third course.
What I am trying to do, with little success, is if they selected 3 courses, and they haven't selected an option from each of the courses a javascript alert pops up.
Can anyone help?
Many Thanks.
<html>
<head>
<title>My Page</title>
<script language="JavaScript" type="text/javascript">
<!--
function classNumber(c, r2, r3) {
if (c.value==1) {
for (var i = 0; i < r2.length; i++)
r2[i].disabled=true;
for (var i = 0; i < r3.length; i++)
r3[i].disabled=true;
}
else if (c.value==2) {
for (var i = 0; i < r2.length; i++)
r2[i].disabled=false;
for (var i = 0; i < r3.length; i++)
r3[i].disabled=true;
}
else if(c.value==3) {
for (var i = 0; i < r2.length; i++)
r2[i].disabled=false;
for (var i = 0; i < r3.length; i++)
r3[i].disabled=false;
}
}
//-->
</script>
</head>
<body>
<form name="myForm" action="YOUR_ACTION_HERE" method="post">
Select the number of courses
<select name="classes" onChange="javascript:classNumber(this, document.myForm.radio2, document.myForm.radio3);">
<option value="1"> 1</option>
<option value="2"> 2</option>
<option value="3"> 3</option>
</select>
<br><br>
<input type="radio" name="radio1" value="option1" checked />Option 1
<input type="radio" name="radio1" value="option2" />Option 2
<input type="radio" name="radio1" value="option3" />Option 3
<br>
<input type="radio" name="radio2" value="option1" disabled="true" checked />Option 1
<input type="radio" name="radio2" value="option2" disabled="true" />Option 2
<input type="radio" name="radio2" value="option3" disabled="true" />Option 3
<br>
<input type="radio" name="radio3" value="option1" disabled="true" checked />Option 1
<input type="radio" name="radio3" value="option2" disabled="true" />Option 2
<input type="radio" name="radio3" value="option3" disabled="true" />Option 3
<br><br>
<input type="submit" value="submit">
</form>
</body>
</html>