0

I have three radio buttons in my JSP page, once selected I would like to show the value of the selected button in div below the radio buttons. find the code below. Based on the selection, I would like to display the value in display.

<div>         
      <div class="service">    
        <input type="radio" name="Service" value="Service1 Selected"      Checked>  <b>Service-1</b></input>                
       <input type="radio" name="Service" value="Service2 Selected"><b>Service-2</b></input>
       <input type="radio" name="Service" value="Service3 Selected"><b>Service-3</b></input>
    </div>
    <div class="display"></div>
Raj550
  • 19
  • 9
  • [link]( http://stackoverflow.com/questions/11689530/two-radio-buttons-are-selecting-at-once?rq=1) check this link might be helpful to you. – khaja firoz Mar 25 '16 at 11:14
  • Thanks, but my requirement is different from the link shared. I don't want to show the value unless it is selected and the value will shown in a div based on the selection – Raj550 Mar 25 '16 at 11:23

1 Answers1

2

try this code

$('input[name="Service"]').on( "click", function() {

$('.display').text($('input[name=Service]:checked').val()); });

foram
  • 76
  • 7
  • Thanks, Its working as expected. Intially one of the radio button is cheked,I would like to display it once page loads. Later it will change based on the selection. – Raj550 Mar 26 '16 at 03:50