Oct 27, 2022
0
Level 1
scrolling menu changing from another scrolling menu
Hello guys,
I've been on this for days and haven't found a solution. I want a scrolling menu depending from the choice of an other :
public function getClientInfo(Request $request)
{
$customerInfo = Customer::find($request->customer_id);
$ClientContactsInfo = ClientContact::where('client_id' , $request->customer_id)->get();
return response()->json(['success' => true, 'response2'=>$ClientContactsInfo, 'response' => $customerInfo]);
}
Javascript :
<script>
$(document).ready(function () {
$('#client_id').trigger('change');
})
$(document).on('change', '#client_id', function () {
var save = '{{url('/')}}/admin/inquiry/getClientInfo';
$.ajax({
url: save,
dataType: "json",
type: "Post",
async: true,
data: {customer_id: $(this).val(), "_token": "{{ csrf_token() }}"},
success: function (row) {
$('#client-email').val(row.response.email);
$('#client-phone').val(row.response.phone);
$('#client-address').val(row.response.address);
$('#agency').val(row.response.first_name);
$('#agency_address').val(row.response.address);
$('#gestionnaire_id2').val(row.response2.email['0']);
},
error: function (xhr, exception) {
alert('There is some error in system 1');
}
});
</script>
and HTML :
<select id="gestionnaire_id2" class="form-control select2">
<option value=""</option>
</select>
Would you have a solution ?
Please or to participate in this conversation.