View Full Version : Form Using Radio Buttons to Redirect

07-15-2010, 01:05 PM
I am trying to create a form that has four questions and the user can select their answer from radio buttons. Depending on their answers, when they hit submit, they are redirected to a new page. Please help! Im new to JS and apologize if my code looks really bad.

Thanks in advance!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Supply Chain Goods Test</title>
<script type="text/javascript">

function whereTo () {
if ((Goods==true) && (Direct==true) && (SoleSource==true))
{ window.location = "http://www.somesite/page1"; }

if ((Goods==true) && (Direct==true) && (NetworkID==true) && (Competed==true))
{ window.location = "http://www.somesite/page2"; }

if ((Goods==true) && (Indirect==true) && (CostCenter==true) && (SoleSource==true))
{ window.location = "http://www.somesite/page3"; }

if ((Goods==true) && (Direct==true) && (NetworkID==true) && (SoleSource==true))
{ window.location = "http://www.somesite/page4"; }

if ((Goods==true) && (Indirect==true) && (CostCenter==true) && (Competed==true))
{ window.location = "http://www.somesite/page5"; }








<form name="RedirectForm" id="RedirectForm">
<table cellpadding="0" cellspacing="0">
<td colspan="2" valign="top"><p>Are you ordering goods or services?</p></td>
<td colspan="2" align="left" valign="middle">
<input type="radio" id="Goods" name="good" /> Goods<br />
<input type="radio" id="Services" name="good" /> Services</td>
<td colspan="2" bgcolor="#EFEFEF"><p>Is your order for a Direct or Indirect charge?</p></td>
<td colspan="2" align="left" valign="middle" bgcolor="#EFEFEF">
<input type="radio" id="Direct" name="charge" /> Direct<br />
<input type="radio" id="Indirect" name="charge" /> Indirect</td>
<td width="600">Do you have a cost center or Network ID</td>
<td align="left" width="150" valign="middle">
<input type="radio" id="CostCenter" name="pay" /> Cost Center<br />
<input type="radio" id="NetworkID" name="pay" /> Network ID</td>
<td height="61" colspan="2"><p>Is your order for a Sole Source or can it be competed?</p></td>
<td colspan="2" align="left" valign="middle">
<input type="radio" id="SoleSource" name="order" /> Sole Source<br />
<input type="radio" id="Competed" name="order" /> Can Be Competed</td>
<td colspan="2" align="right" valign="middle"><input type="submit" value="Submit" onclick="return whereTo()" /></td>


07-15-2010, 08:20 PM
So basically a category type quiz I guess Ill put it?
The majority of a specific category selected gets directed to a page.