Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Radio and Submit Button

    I want to create several options (radio buttons) where only one can be selected. I then want a different webpage to be associated with each choice so when the submit button is press it will go to the webpage that the radio button links to.

    i know how to create a simple radio button and make it so only one can be selected. I am unsure how to do the different links and how to go to the link when a button is pressed. Can someone please help.

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Here's a basic example for you to keep going:
    Code:
    <script type="text/javascript">
    function link(inpName)
    {
    var rad=document.getElementsByName(inpName),store;
    for(var i=0;i<rad.length;i++)
    	store=(rad[i].checked)?'http://www.'+rad[i].value+'.com':store;
    location.href=store;
    }
    </script>
    <label>Google: </label><input type="radio" name="web" value="google"><br>
    <label>Yahoo: </label><input type="radio" name="web" value="yahoo"><br>
    <input type="button" value="Submit" onclick="link('web')"><br><br>
    <label>HF: </label><input type="radio" name="forum" value="htmlforums"><br>
    <label>CF: </label><input type="radio" name="forum" value="codingforums"><br>
    <input type="button" value="Submit" onclick="link('forum')"><br><br>
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph


  •  

    Posting Permissions

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