0

I have two web pages A and B. Webpage A contains some radio buttons. I just want that if the user selects any of the radio button, webpage B should be opened.

Can anyone help me regarding what should I try to do this?

user2110239
  • 134
  • 1
  • 1
  • 11
  • You can do this with JavaScript. Side note: using radio buttons for redirecting to a web page is not so user friendly and the intention of the [radio buttons is another](http://www.w3.org/TR/html401/interact/forms.html). There are anchor elements (links) for redirecting. – keenthinker Jan 19 '14 at 11:48

3 Answers3

2

Your need to add the onclick attribute to your radiobuttons in this way:

<input type='radio' onclick='functionCalled()' />

Then under the radio buttons add:

<script>
     function functionCalled() {
          window.open(url); //if you want to open in new window
          window.location = url; //if you want to redirect
     }
</script>
BenMorel
  • 34,448
  • 50
  • 182
  • 322
1

HTML alone is not enough. You will need to start learning JavaScript (and preferably jQuery as well).

Assuming you have jQuery:

<input type="radio" name="mything" value="1"/>
<input type="radio" name="mything" value="0"/>

$('input:radio[name="mything"]').change(
    function(){
        if ($(this).is(':checked') && $(this).val() == '1') {
            window.location = "http://www.yoururl.com";
        }
        else{
            window.location = "http://www.yourotherurl.com";
        }
    });

Javascript redirect: How to redirect to another webpage in JavaScript/jQuery?

Radio Button selected: Jquery If radio button is checked

Community
  • 1
  • 1
Nathan H
  • 48,033
  • 60
  • 165
  • 247
1

Try this:

<input type="radio" onchange="window.location.replace('URL_OF_WEBSITE')">
Bhushan
  • 6,151
  • 13
  • 58
  • 91