Web Analytics Made Easy -
StatCounter radio button choices for page redirect - CodingForum

Announcement

Collapse
No announcement yet.

radio button choices for page redirect

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • radio button choices for page redirect

    I'm designing a page that allows the user to choose from 3 different sets of radio button options, then click to be redirected to a page that is appropriate to the selection.

    Any help will be appreciated. (Many of the links in this example are repeated, the working code will contain unique links.)

    Thanks,

    Jean

    Here is the code:

    <html>
    <head>
    <title>More Choices</title>
    <script language="JavaScript">
    var allOne = new Array ();
    allOne[0] = "http://www.maskwoman.biz";
    allOne[1] = "http://www.maskwoman.biz/catalog.htm#catalog";
    allOne[2] = "http://www.maskwoman.biz/animals.htm";
    allOne[3] = "http://www.maskwoman.biz/fantasy.htm#fantasy";
    allOne[4] = "http://www.maskwoman.biz/portraits.htm";

    var businessOne = new Array ();
    businessOne[0] = "http://www.maskwoman.biz";
    businessOne[1] = "http://www.maskwoman.biz/catalog.htm#catalog";

    var masksOne = new Array ();
    masksOne[0] = "http://www.maskwoman.biz/animals.htm";
    masksOne[1] = "http://www.maskwoman.biz/fantasy.htm#fantasy";
    masksOne[2] = "http://www.maskwoman.biz/portraits.htm";

    var allTwo = new Array ();
    allTwo[0] = "http://www.maskwoman.biz";
    allTwo[1] = "http://www.maskwoman.biz/catalog.htm#catalog";
    allTwo[2] = "http://www.maskwoman.biz/animals.htm";
    allTwo[3] = "http://www.maskwoman.biz/fantasy.htm#fantasy";
    allTwo[4] = "http://www.maskwoman.biz/portraits.htm";

    var businessTwo = new Array ();
    businessTwo[0] = "http://www.maskwoman.biz";
    businessTwo[1] = "http://www.maskwoman.biz/catalog.htm#catalog";

    var masksTwo = new Array ();
    masksTwo[0] = "http://www.maskwoman.biz/animals.htm";
    masksTwo[1] = "http://www.maskwoman.biz/fantasy.htm#fantasy";
    masksTwo[2] = "http://www.maskwoman.biz/portraits.htm";

    var allThree = new Array ();
    allThree[0] = "http://www.maskwoman.biz";
    allThree[1] = "http://www.maskwoman.biz/catalog.htm#catalog";
    allThree[2] = "http://www.maskwoman.biz/animals.htm";
    allThree[3] = "http://www.maskwoman.biz/fantasy.htm#fantasy";
    allThree[4] = "http://www.maskwoman.biz/portraits.htm";

    var businessThree = new Array ();
    businessThree[0] = "http://www.maskwoman.biz";
    businessThree[1] = "http://www.maskwoman.biz/catalog.htm#catalog";

    var masksThree = new Array ();
    masksThree[0] = "http://www.maskwoman.biz/animals.htm";
    masksThree[1] = "http://www.maskwoman.biz/fantasy.htm#fantasy";
    masksThree[2] = "http://www.maskwoman.biz/portraits.htm";

    var levelOne = "(document.adventure.level.one.checked)?true:false";
    var levelTwo = "(document.adventure.level.two.checked)?true:false";
    var levelThree = "(document.adventure.level.three.checked)?true:false";

    var shorter = "(document.choose.where.first.checked)?true:false";
    var short1 = "(document.choose.where.second.checked)?true:false";
    var long1 = "(document.choose.where.third.checked)?true:false";

    var nothanks = "(document.list.not.no.checked)?true:false";
    var yesplease = "(document.list.not.yes.checked)?true:false";


    function whereTo () {
    if (levelOne && shorter && nothanks == true) {
    window.location = masksOne[Math.floor(Math.random() * masksOne.length)];
    }
    if (levelOne && short1 && nothanks == true) {
    window.location = businessOne[Math.floor(Math.random() * businessOne.length)];
    }
    if (levelOne && long1 && nothanks == true) {
    window.location = allOne[Math.floor(Math.random() * allOne.length)];
    }
    if (levelTwo && shorter && nothanks == true) {
    window.location = masksTwo[Math.floor(Math.random() * masksTwo.length)];
    }
    if (levelTwo && short1 && nothanks == true) {
    window.location = businessTwo[Math.floor(Math.random() * businessTwo.length)];
    }
    if (levelTwo && long1 && nothanks == true) {
    window.location = allTwo[Math.floor(Math.random() * allTwo.length)];
    }
    if (levelThree && shorter && nothanks == true) {
    window.location = masksThree[Math.floor(Math.random() * masksThree.length)];
    }
    if (levelThree && short1 && nothanks == true) {
    window.location = businessThree[Math.floor(Math.random() * businessThree.length)];
    }
    if (levelThree && long1 && nothanks == true) {
    window.location = allThree[Math.floor(Math.random() * allThree.length)];
    }
    if (levelOne && shorter && yesplease == true) {
    window.location = "http://www.maskwoman.biz";
    }
    if (levelOne && short1 && yesplease == true) {
    window.location = "http://www.maskwoman.biz";
    }
    if (levelOne && long1 && yesplease == true) {
    window.location = "http://www.maskwoman.biz";
    }
    if (levelTwo && shorter && yesplease == true) {
    window.location = "http://www.maskwoman.biz";
    }
    if (levelTwo && short1 && yesplease == true) {
    window.location = "http://www.maskwoman.biz";
    }
    if (levelTwo && long1 && yesplease == true) {
    window.location = "http://www.maskwoman.biz";
    }
    if (levelThree && shorter && yesplease == true) {
    window.location = "http://www.maskwoman.biz";
    }
    if (levelThree && short1 && yesplease == true) {
    window.location = "http://www.maskwoman.biz";
    }
    if (levelThree && long1 && yesplease == true) {
    window.location = "http://www.maskwoman.biz";
    }
    }
    </script>
    </head>

    <body>
    <p><h3>Choose a level</h3></p>
    <form name="adventure">
    <input type="radio" name="level" value="one">First List<br>
    <input Type="radio" name="level" value="two">Second List<br>
    <input type="radio" name="level" value="three">Third List<br>
    </form>
    <h3>What do you want to see?</h3>
    <form>
    <form name ="choose">
    <input type="radio" name="where" VALUE="first"> Conduct Business<br>
    <input type="radio" name="who" VALUE="second"> Look at Masks<br>
    <input type="radio" name="who" value="third"> All
    </form>
    <h3>Print a list?</h3>
    <form>
    <form name = "list">
    <input type="radio" name="not" VALUE="No"> No<br>
    <input type="radio" name="not" VALUE="Yes"> Yes<br>
    <input type="button" onclick=" return whereTo()" value="Where?">
    </form>
    </body>
    </html>

  • #2
    radio button - choise - link

    Just like prizsm I'm designing a page that allows the user to choose from 3 different sets of radio buttons, the combination have to lead to a certain link.

    this code (on top) doesn't work properly. It won't give a link to the next page

    I think the radio buttons should have a certain value. For example
    1-2
    3-4
    4-5

    the combination 1-4-5 = go to 145.html

    hopefully somebody can help me out
    -karin-


    this is what i have for so far:

    <html>
    <head>
    <title>set radio buttons link</title>
    <script language="JavaScript">
    <!--
    function subForm()
    {
    var j = 0;
    var radio_buttons = new Array();
    var the_form = window.document.forms[0];
    for(var i=0; i<the_form.length; i++)
    *****{
    *****var temp = the_form.elements[i].type;
    *****if((temp == "radio") && (the_form.elements[i].checked)) { radio_buttons[j] = the_form.elements[i].value; j++; }
    *****}
    for(var k=0; k<radio_buttons.length; k++)
    *****{
    *****document.write(radio_buttons[k] + "<br>");
    *****}
    }
    //-->
    </script>

    </head>
    <body><table border="0" cellspacing="0" cellpadding="10">
    <tr>
    <td width="120"><form action="javascript: subForm();" name="business card" id="business card">
    <p><font size="1" face="Geneva, Arial, Helvetica, sans-serif">


    <input type="radio" name="button_1" value="1">1<br>
    <input type="radio" name="button_1" value="2">2<br>
    <br>
    <input type="radio" name="button_2" value="3">3<br>
    <input type="radio" name="button_2" value="4">4<br>
    <br>
    <input type="radio" name="button_3" value="5">5<br>
    <input type="radio" name="button_3" value="6">6</font></p>


    <p><font size="1" face="Geneva, Arial, Helvetica, sans-serif"><br>
    <br>
    <input name="submit" type="submit" value="GO!">
    </font> </p>
    </form></td>


    <td width="40">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </body>
    </html>
    Last edited by -karin-; Jun 17, 2005, 03:20 PM.

    Comment

    Working...
    X