cdenkers
07-14-2010, 05:05 PM
I am trying to build a page that has a form on it with three questions, each having two answers via radio button. When the user hits submit, depending on their answers to the three questions, it redirects them to a different page.
This is all I have so far and am stuck, I dont know much JS.
<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"; }
if ((Goods==true) && (Direct==true) && (NetworkID==true) && (Competed==true))
{ window.location = "http://www.somesite/page6"; }
}
</script>
The form (it only has the inputs not the questions, i know its not setup properly, just wanted to show the inputs):
<form>
<input type="radio" id="Goods" name="good" /> Goods<br /><input type="radio" id="Services" name="Services" /> Services
<input type="radio" id="Direct" name="good" /> Direct<br /><input type="radio" id="Indirect" name="Indirect" /> Indirect
<input type="radio" id="CostCenter" name="CostCenter" /> Cost Center<br /><br /><input type="radio" id="NetworkID" name="NetworkID" /> Network ID
<input type="radio" id="SoleSource" name="order" /> Sole Source<br /><input type="radio" id="Competed" name="order" /> Can Be Competed</td>
<input alt="Submit" onclick=" return whereTo()" />
</form>
This is all I have so far and am stuck, I dont know much JS.
<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"; }
if ((Goods==true) && (Direct==true) && (NetworkID==true) && (Competed==true))
{ window.location = "http://www.somesite/page6"; }
}
</script>
The form (it only has the inputs not the questions, i know its not setup properly, just wanted to show the inputs):
<form>
<input type="radio" id="Goods" name="good" /> Goods<br /><input type="radio" id="Services" name="Services" /> Services
<input type="radio" id="Direct" name="good" /> Direct<br /><input type="radio" id="Indirect" name="Indirect" /> Indirect
<input type="radio" id="CostCenter" name="CostCenter" /> Cost Center<br /><br /><input type="radio" id="NetworkID" name="NetworkID" /> Network ID
<input type="radio" id="SoleSource" name="order" /> Sole Source<br /><input type="radio" id="Competed" name="order" /> Can Be Competed</td>
<input alt="Submit" onclick=" return whereTo()" />
</form>