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

Radio Buttons

Status
Not open for further replies.

techu4

Technical User
Jun 27, 2005
32
GB
Hi,

I am trying to create a form that has 6 questions with yes no radio buttons.

The first five have to be answered as yes and if they are not I need to load a new html page.

The last question needs to load a different page dependant on which radio button is selected, but only if all if the first five questions are answered yes.

Unfortunately I am not that familiar with javascript so could do with some help to get me on the right track.

Hope this makes sense

Regards

Techu4

 
Hi,

I have worked out most of the code but seem to have a problem.

I need the code to check if any of the groups of radio buttons are checked as no and if so to redirect to another page. At the moment it only redirects if all radio buttons are set to no.

The last group of radio buttons determines what page to load if all the others are set to yes.

Code:
<script language="JavaScript">

function subForm(){
var allok = true;
var frm = document.entry;

if(frm.group1[0].checked) {
    allok = false;
}
else if(frm.group2[0].checked) {
	allok = false;
}
if (allok){
		false;
actionPage = "PAGE TO GO TO IF ONE OF THE RADIO BUTTONS IS CHECKED NO";
    frm.action = actionPage;
   	frm.submit();
}
else {
tenhom();
}

}
function tenhom(){
var frm1 = document.entry;

if(frm1.group3[0].checked) {
actionPage = "PAGE TO GO TO IF FIRST RADIO BUTTON CHECKED";
    frm1.action = actionPage;
   	frm1.submit();
}
else if(frm1.group3[1].checked) {
actionPage = "PAGE TO GO TO IF SECOND RADIO BUTTON CHECKED";
    frm1.action = actionPage;
   	frm1.submit();
}
}

</script>

And here is the form code.

Code:
<form id="entry" name="entry" >
<div id="page1"  class="page" style="display:block;">
  <table border="0" cellpadding="0" cellspacing="0" width="100%" id="table3">
	<tr>
		<td colspan="5"><b>Loan Application Basic Criteria</b></td>
	</tr>
	<tr>
		<td width="17%">&nbsp;</td>
		<td width="6%">&nbsp;</td>
		<td width="32%">&nbsp;</td>
		<td width="7%">&nbsp;</td>
		<td width="39%">&nbsp;</td>
	</tr>
	<tr>
		<td width="17%">&nbsp;</td>
		<td width="6%">&nbsp;</td>
		<td width="32%"><input type="radio" name="group1" value="Yes" checked>Yes</td>
		<td width="7%">&nbsp;</td>
		<td width="39%"><input type="radio" name="group1" value="No">No</td>
	</tr>
		<tr>
		<td width="17%">&nbsp;</td>
		<td width="6%">&nbsp;</td>
		<td width="32%"><input type="radio" name="group2" value="Yes" checked>Yes</td>
		<td width="7%">&nbsp;</td>
		<td width="39%"><input type="radio" name="group2" value="No" >No</td>
	</tr>
		<tr>
		<td width="17%">&nbsp;</td>
		<td width="6%">&nbsp;</td>
		<td width="32%"><input type="radio" name="group3" value="Homeowner" checked>Homeowner</td>
		<td width="7%">&nbsp;</td>
		<td width="39%"><input type="radio" name="group3" value="Tenant" >Tenant</td>
	</tr>
		<tr>
		<td width="17%">&nbsp;</td>
		<td width="6%">&nbsp;</td>
		<td width="32%"><input type="submit" value="Continue" onclick="subForm();"></td>
		<td width="7%">&nbsp;</td>
		<td width="39%">&nbsp;</td>
	</tr>
	</table>
  
</div>

</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top