www.webdeveloper.com
Results 1 to 2 of 2

Thread: radio button determines link

  1. #1
    Join Date
    May 2004
    Posts
    17

    radio button determines link

    Hi
    Is it possible to do the following:

    Have a form on a page with several radio buttons.
    Depending which radio button is checked, the "submit" button links to a different page.

    I've tried setting the value of a variable to "one.htm" or "two.htm" depending on which radio button is checked, and then putting the variable here

    <form name="form1" method="post" function called here action= variable>

    is this the right idea

    I'm sorry I'm not posting the script, but I'm not at my own computer right now and thought I'd try my luck
    Last edited by Masha Stekker; 05-27-2004 at 07:52 AM.

  2. #2
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    Hi!

    You could try something like:
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    title>Untitled</title>
    <
    script language="JavaScript" type="text/javascript">
    <!--
    function 
    radioCheck(frm){
    rad=frm.url;
    for (var 
    i=0;i<rad.length;i++){
    if(
    rad[i].checked==true){
    frm.action=rad[i].value;
    }
    }
    //maybe other code here for some validation
    return true;
    }
    //-->
    </script>
    </head>
    <body>
    <form name="form1" method="post" action="#" onsubmit="return radioCheck(this)">
    <input type="radio" name="url" value="one.htm" checked> one.htm<br>
    <input type="radio" name="url" value="two.htm"> two.htm<br>
    <input type="submit">
    </body>
    </html> 
    Cheers - Pit

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles