1

I have two radio in my blade and i want if radio 1 checked display some step in modal popup
else if radio 2 checked display another step in this modal event

this is my radio in view :

  <div class="row setup-content" id="step-1">
  <div class="col-xs-6 col-md-offset-3">
  <div class="col-md-12">
  <h3> Step 1</h3>
  <label><input type="radio" class="message_pri" id="web" name="web" value="Web">Web</label>
  <label><input type="radio" class="message_pri" id="mobile" name="web" value="Mobile">Mobile</label>
  <button class="btn btn-primary nextBtn btn-lg pull-right btnnext" type="button" >Next</button>
</div>

Jonas
  • 121,568
  • 97
  • 310
  • 388
C.Azzeddine
  • 25
  • 2
  • 7
  • you need to check it in javascript? – kRicha Jun 08 '17 at 12:12
  • You can use jQuery to check for it [find-out-if-radio-button-is-checked-with-jquery](https://stackoverflow.com/questions/2272507/find-out-if-radio-button-is-checked-with-jquery) – rbaskam Jun 08 '17 at 12:13
  • Possible duplicate of [Find out if radio button is checked with JQuery?](https://stackoverflow.com/questions/2272507/find-out-if-radio-button-is-checked-with-jquery) – rbaskam Jun 08 '17 at 12:14

2 Answers2

1

Try this:

$('.message_pri').change(function(){
  if($(this).val() == 'Web')
  {
    alert('Web is selected')
  }
  else
  {
    alert('Mobile is selected')
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="row setup-content" id="step-1">
  <div class="col-xs-6 col-md-offset-3">
  <div class="col-md-12">
  <h3> Step 1</h3>
  <label><input type="radio" class="message_pri" id="web" name="web" value="Web">Web</label>
  <label><input type="radio" class="message_pri" id="mobile" name="web" value="Mobile">Mobile</label>
  <button class="btn btn-primary nextBtn btn-lg pull-right btnnext" type="button" >Next</button>
</div>
Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59
0

You can done this with another simply way Just add this script to your page

        $('.message_pri').on('change',function(){
        if($('#web').is(':checked')){
            alert('web');
        }else{
            alert('mobile');
        }
    })

Check here:-https://jsfiddle.net/Bibhudatta_sahoo/5cy19n1w/

Bibhudatta Sahoo
  • 4,808
  • 2
  • 27
  • 51