Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q576 How can I make a form which has three sections of radio buttons that will take the user to a specific page based upon their selections?

You are here: irt.org | FAQ | JavaScript | Form | 8 | Q576 [ previous next ]

It depends on what you are trying to do, but the following might give you some ideas:

<html>
<head>

<script language="JavaScript"><!--
function go(what) {
    for (var i=0; i<3; i++) {
        if (what.one[i].checked == true)
            var one = what.one[i].value;
        if (what.two[i].checked == true)
            var two = what.two[i].value;
        if (what.three[i].checked == true)
            var three = what.three[i].value;
    }

    location.href = one + two + three;
}
//--></script>

</head>

<body>

<form>
a: <input type="radio" name="one" value="a" checked>
b: <input type="radio" name="one" value="b">
c: <input type="radio" name="one" value="c">

<br>

1: <input type="radio" name="two" value="1">
2: <input type="radio" name="two" value="2" checked>
3: <input type="radio" name="two" value="3">

<br>

.htm: <input type="radio" name="three" value=".htm">
.html: <input type="radio" name="three" value=".html">
.txt: <input type="radio" name="three" value=".txt" checked>

<p>

<input type="button" onClick="go(this.form)" value="Go">
</form>

</body>

©2018 Martin Webb