How to use jQuery to load the values in the form fields when the corresponding radio button is selected?

How to use jQuery to load the values in the form fields when the corresponding radio button is selected?

 have a form that has some radio buttons. Each radio button corresponds to a registration type of a conference. For that I have this code:



  1.  @foreach($registrationType as $rtype)
  2.       <div class="form-check">
  3.         <input class="form-check-input" type="radio" name="radiobutton" id="{{$rtype->id}}" value="option1">
  4.         <label class="form-check-label" for="exampleRadios1">
  5.           {{$rtype->name}}
  6.         </label>
  7.       </div>
  8.   @endforeach

Below the radio buttons, the form has some fields and I want to show in this fields the information of each selected registration type. This part I'm in doubt how to do it.


First I load the values for each registration type and store them in a array:


  1.  $(function() {
  2.     var registrationTypes = {!!  $registrationTypeJson !!}
  3.     alert(registrationTypes) // returns "[object Object]""
  4. });

But then how to use jquery to load the values in the form fields when the corresponding radio button is selected? 


Full form:


  1. <form method="post" class="clearfix">
  2.       <div class="form-row">
  3.         <div class="form-group col col-lg-6">
  4.           <label for="registration_types">Registration Types</label>

  5.           @foreach($registrationType as $rtype)
  6.           <div class="form-check">
  7.             <input class="form-check-input" type="radio" name="radiobutton" id="{{$rtype->id}}" value="option1">
  8.             <label class="form-check-label" for="exampleRadios1">
  9.               {{$rtype->name}}
  10.             </label>
  11.           </div>
  12.           @endforeach

  13.       </div>
  14.       </div>
  15.       <div class="form-group">
  16.         <label for="registration_type_name">Registration Type Name</label>
  17.         <input type="text" required class="form-control" value="{{ $rtype->nome }}" name="registration_type_name" id="registration_type_name">
  18.       </div>
  19.       <div class="form-group">
  20.         <label for="registration_type_capacity">Capacity</label>
  21.         <input type="number" min="1"
  22.                required class="form-control" value="{{ $rtype->capacity }}"
  23.              name="registration_type_capacity" id="registration_type_capacity">
  24.       </div>
  25.       <!-- more registration type info fields -->
  26.       </div>
  27.     <input type="submit" class="btn btn-primary" value="Update registration type"/>
  28.     </form>