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

Web Form Check Boxs To Send To Another Page

Status
Not open for further replies.

jereece

Technical User
Jun 15, 2002
9
0
0
US
I am looking for a javascript code that works in a form so that depending on which check boxes are checked, the form will send the user to a particular web page. For example, lets say I have a web form with 3 check boxes (A, B and C). If a user clicks on check box A only, then clicks OK, they would be take to A.htm. Same for B and C only. If however, they check A and B, they would be taken to AB.htm. If they check AC they would be taken to AC.htm. If BC then BC.htm. If ABC then ABC.htm. If none is checked, the would be taken to 0.htm. You get the idea.

The reason I want to do this is I want to users to answer a set of questions and depending on their answers get them to the right web page.

If you have any other suggestions how to accomplish this, I am open to that as well.

Thanks for your help.

Jim
 
Never mind. I got a reply from another web site. In case anyone is interested, here's the solution:

<script>
function go(fm) {
var url = &quot;.htm&quot;;
if (fm.C.checked) url = &quot;C&quot; + url;
if (fm.B.checked) url = &quot;B&quot; + url;
if (fm.A.checked) url = &quot;A&quot; + url;
if (url == &quot;.htm&quot;) url = &quot;0.htm&quot;;
window.location = url;
}
</script>
<form onsubmit=&quot;return false&quot;>
A:<input name=&quot;A&quot; type=&quot;checkbox&quot; value=&quot;A&quot;><br>
B:<input name=&quot;B&quot; type=&quot;checkbox&quot; value=&quot;B&quot;><br>
C:<input name=&quot;C&quot; type=&quot;checkbox&quot; value=&quot;C&quot;><br>
<input type=&quot;button&quot; value=&quot; Go &quot; onClick=&quot;go(this.form)&quot;>
</form>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top