45 users online (0 members and 45 guests)  


  Results 1 to 2 of 2

Related

  1. Remembering multiple selections    Forum: CGI Perl Forum
    Replies: 1
  2. Replies: 4
  3. Help parsing html for URLs    Forum: CGI Perl Forum
    Replies: 0
  4. Keep meta tags with domain forward    Forum: HTML Forum
    Replies: 5
  5. back and forward tags....    Forum: HTML Forum
    Replies: 2
  1. #1
    lacey's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2005
    Posts
    1

    Making Radiobox selections forward to specific URLs

    Hey guys, I'm completely new to Javascript but i'm sure it's capable of this;

    I have 3 Radioboxes on a page, followed by a 'Submit' button. eg;

    () Radiobox 1

    () Radiobox 2

    () Radiobox 3

    [SUBMIT]

    That was just done with HTML, so there is no functionality at present (not even any form tags).

    When the user selects a radiobox and then clicks 'Submit', I want him/her to be forwarded to a different URL depending upon which radiobox was chosen. For instance, selecting Radiobox 1 and clicking 'Submit' should send the user to URL A. Selecting Radiobox 2 and clicking 'Submit' should send the user to URL B, and so forth.

    I'm sorry for asking the ultimate newbie question, but where do I start? Does anybody have any ideas about how to code something like this?

    Thanks guys!

  2. #2
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316

    Re: Making Radiobox selections forward to specific URLs

    HTML Code:
    <head>
    <script language=Javascript>
    <!--
    function fnJump()
    {
    	var URL='';
    	for (var i = 0; i < document.FormName.RadioBox.length ; ++i)
    	{
    		if (document.FormName.RadioBox(i).checked == true)
    		{
    			URL = document.FormName.RadioBox(i).value
    		}
    	}
    
    	if (URL.length > 0)
    	{
    		window.location = URL;
    	}
    	else
    	{
    		alert('No radiobox selected');
    	}
    }
    -->
    </script>
    </head>
    <body>
    <form name=FormName>
    <input type=radio name=RadioBox value='http://www.google.com.my/'>www.google.com.my
    <input type=radio name=RadioBox value='http://mail.google.com/'>mail.google.com
    <input type=radio name=RadioBox value='http://www.r2.com.au/'>www.r2.com.au
    <input type=button name=btnSubmit value=Submit onclick='fnJump();'>
    </form>
    </body>