-1

Script

$('document').ready(function() {
  $('#conbtn').click(function() {
    if ($('#radio1').is(':checked') $('#radio1').is(':checked') $('#radio1').is(':checked')) {

      $(location).attr('href', 'career-central-choice.html');
    } else {

      alert('Please Select One Stream');

    }
  });
});

HTML

<div class="select-stream">
    <div class="second_slide">
        <form>
            <input type="radio" name="sub_1" id="radio1">
            <label>Science</label>
            <input type="radio" name="sub_1" id="radio2">
            <label>Commerce</label>
            <input type="radio" name="sub_1" id="radio3">
            <label>Humanities/Arts</label>
            <br>
            <button id="conbtn">Continous</button>
        </form>
    </div>
</div>

How to redirect to another page on select using a radio button?

Satpal
  • 132,252
  • 13
  • 159
  • 168

3 Answers3

1
if ($('#radio1').is(':checked')) {
    location.href=/*your url*/;
}
Hans Roerdinkholder
  • 3,000
  • 1
  • 20
  • 30
Buisson
  • 479
  • 1
  • 6
  • 23
0

You need to use || operator and use correct ID selector.

Use

$('document').ready(function() {
    $('#conbtn').click(function() {
        if ($('#radio1').is(':checked') || 
            $('#radio2').is(':checked') || 
            $('#radio3').is(':checked')) {
            $(location).attr('href', 'career-central-choice.html');
        } else {
            alert('Please Select One Stream');
        }
    });
});
Satpal
  • 132,252
  • 13
  • 159
  • 168
0

You can add params <form id="form" action="career-central-choice.html">.

and in JS:

$('document').ready(function() {
$('#form').submit(function() {
    if (!$('#radio1').is(':checked') && 
        !$('#radio2').is(':checked') && 
        !$('#radio3').is(':checked')) {
        alert('Please Select One Stream');
        return false; // this row disables form sending
    }
});
});
Vadim S
  • 358
  • 1
  • 15