javascript - GET data from select2 Laravel and pass to input form -


i have value select2 i've create it. when click it, parse value of name form i've created it. how can display value form have created. sorry bad english.

this script

<script type="text/javascript">         $(document).ready(function() {             $(".customer_select2").select2({                 tags: 'true',                 placeholder: 'search crm',                 allowclear: true             });         });         $(".customer_select2").change(function() {             var customer_select2 = $(this).val();             getcustomerlist(customer_select2);         });         function addcustomer() {             $('#createcustomermodal').modal('show');         }         function getcustomerlist(customer_list, customer_no, name, address, birthdate, identity_number, gender, phone) {             $.ajax({                 url: 'http://localhost:8000/api/v1/customer/'+ customer_list,                 type: 'get',                 datatype: 'json',                 success: function (response) {                     $('').val();                     $('#customernoloan').val(customer_no);                     $('#nameloan').val(name);                     $('#addressloan').val(address);                     $('#identity_numberloan').val(identity_number);                     $('#phoneloan').val(phone);                 },                 error: function(response){                     alert(response);                 }             })              }     </script> 

this blade

<div class="form-group">     <select class="customer_select2 form-control" id="customer_list" style="width: 150px;" onchange="getcustomerlist(this.value)">         <option value=""></option>         @foreach($customer_list $key => $value)             <option value="{{ $key }}">{{ $value }}</option>         @endforeach     </select>                             <div class="form-group{{ $errors->has('customer_no') ? ' has-error' : '' }}">                                 {!! form::label('customer_no', 'customer no. :') !!}                                 {!! form::text('customer_no', old('customer_no'), ['class' => 'form-control', 'id' => 'customernoloan', 'autofocus', 'readonly' => 'true']) !!}                                 @if ($errors->has('customer_no'))                                     <span class="help-block">                                         <strong>{{ $errors->first('customer_no') }}</strong>                                     </span>                                 @endif                             </div>                              <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">                                 {!! form::label('name', "name") !!}                                 {!! form::text('name', old('name'), ['class'=>'form-control','id'=>'nameloan','autofocus', 'readonly' => 'true']) !!}                                 @if ($errors->has('name'))                                     <span class="help-block">                                         <strong>{{ $errors->first('name') }}</strong>                                     </span>                                 @endif                             </div> 


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -