In this tutorial we’re going to learn how to using Onchange function in laravel using javscript.
Put below code
onsole.log('email me ky aa gaya edit ke page pe' + html.data.admin_email);
if ($('#project_manager option[value="' + adminEmail + '"]').length ===
0) {
$('#project_manager').append('<option value="' + adminEmail + '">' +
adminEmail + '</option>');
}
$('#project_manager').val(adminEmail);
Next put below code
$(document).on('click', '.edit', function() {
console.log('working edit button');
$('#name_form').show();
var id = $(this).attr('id');
$('#form_result').html('');
$.ajax({
type: "get",
data: {},
url: "{{ url('/api/v1/j/project/edit/') }}/" + id,
headers: {
"Authorization": "Bearer " + localStorage.getItem('a_u_a_b_t')
},
success: function(html) {
var adminEmail = html.data.admin_email;
if ($('#project_manager option[value="' + adminEmail + '"]').length ===
0) {
$('#project_manager').append('<option value="' + adminEmail + '">' +
adminEmail + '</option>');
}
$('#project_manager').val(adminEmail);
console.log('value aa gaya edit ke page pe');
console.log('email me ky aa gaya edit ke page pe' + html.data
.admin_email);
console.log(html);
$('#project_name').val(html.data.project_name);
$('#project_manager').val(html.data.admin_email);
$('#url').val(html.data.url);
$('#sa_id').val(html.data.sa_id);
$('#sa_email').val(html.data.admin_email);
$('.modal-title').text("Edit Project");
$('.modal-title_delete').text("Project Delete");
$('#action_button').val("Update");
$('#action').val("Update");
$('#formModal').modal('show');
$('#hidden_id').val(id);
}
})
});
Go to blade page and put below code
<div class="form-group" id="name_form">
<label class="control-label">Project Manager</label>
<select name="project_manager" id="project_manager" class="w-100 p-2">
<option value="" class="form-controll text-dark">Select Manager </option>
<option value="{{ Auth::user()->email }}">{{ Auth::user()->email }}</option>
</select>
</div>