homepage Welcome to WebmasterWorld Guest from 54.211.157.103
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Checking the condition of 3 banks of radio buttons
How can it be done?
bondjamesbond




msg:1485725
 1:08 pm on Nov 11, 2003 (gmt 0)

Hi,

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.

 

mikegram




msg:1485726
 4:48 am on Nov 12, 2003 (gmt 0)

This isn't quite what you asked for, but it might work for you. The banks of radio buttons are enabled/disabled based on the number of courses selected. Each bank is given a default value. Only 3 options per bank are listed here, but it should work with as many as you like. (tested IE6, Netscape 7, Opera 7.21 -- negative on NN4.x)

<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>

bondjamesbond




msg:1485727
 9:47 am on Nov 12, 2003 (gmt 0)

Thanks mikegram, while it's not exactly what I was looking for, it gives me ideas and I can use it.

Many thanks for your time.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved