1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Select Radio Button Then Redirects to Specific Page When Submit is Clicked

Discussion in 'JavaScript' started by stevethower, Feb 14, 2011.

  1. #1
    Hi,

    I wondered what was involved in creating a script that I can use on a WordPress page.
    SEMrush
    Specifically the person wants a list of radio buttons and when they select the appropriate radio button and hit submit it redirects to a specific URL.

    Like:

    Where Are You?

    Select Canada Radio Button >> Redirects to Canadian Content Page or URL
    Select USA Radio Button >> Redirects to USA Content Page or URL

    Thanks
     
    stevethower, Feb 14, 2011 IP
    SEMrush
  2. pHrEaK

    pHrEaK Active Member

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    That would actually be fairly easy. You would just have to pass the value of the radio button to a function that depending on the value would link the user to whichever page. Are you looking for the code to do this or just curious as to how easy it is? A programmer with just basic java knowledge should be able to accomplish this fairly easily
     
    pHrEaK, Feb 14, 2011 IP
  3. stevethower

    stevethower Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Looking for the code that I can use on a WordPress site for a charity...
     
    stevethower, Feb 14, 2011 IP
  4. pHrEaK

    pHrEaK Active Member

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    If no one else has chimed in by the time i get back to my layer, i'll see what i can put together for an example
     
    pHrEaK, Feb 14, 2011 IP
  5. stevethower

    stevethower Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks a lot...
     
    stevethower, Feb 14, 2011 IP
  6. pHrEaK

    pHrEaK Active Member

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Alright I put together a simple example of what it is I'm thinking that your wanting to accomplish.
    Simple Example of Radio Button Links With submit button
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD//XHTML 1.0
    Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml"
    xml : lang="en" lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    <title>radioButtons</title>
    
    <script type="text/javascript">
    /* <![CDATA[ */
    function sub() {
    window.location.href = site;
    }
    function goTo(URL) {
    site = URL;
    }	
    /* ]]> */
    </script>
    
    </head>
    
    <body>
    	<form  name="frmSite">
    		<input type="radio" name="site" onchange="if(this.checked){goTo('http://www.google.com')}"/>Google<br/>
    		<input type="radio" name="site" onchange="if(this.checked){goTo('http://www.youtube.com')}"/>Youtube<br/>
    		<input type="radio" name="site" onchange="if(this.checked){goTo('http://www.facebook.com')}"/>Facebook<br/>
    		<input type="radio" name="site" onchange="if(this.checked){goTo('http://www.ebay.com')}"/>Ebay<br/>
    		<input type="Button" value="Submit" onclick="sub()" />
    	</form>
    </body>
    
    </html>
    
    Code (markup):
     
    pHrEaK, Feb 14, 2011 IP
  7. pHrEaK

    pHrEaK Active Member

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #7
    That's about all i can do in my power without seeing the site, the code for it, and knowing exactly what your wanting...hope that helps
     
    pHrEaK, Feb 14, 2011 IP
  8. stevethower

    stevethower Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks... it worked in the WordPress site I am doing for a Network of Angels group.
     
    stevethower, Feb 15, 2011 IP