Frontend;
$.ajax({
url: '{{ route('diffacts.manage.confirm.process') }}?a=e&id=' data.id,
method: 'GET',
data: {
date_start: $('#date_start').val(),
duration: $('#duration').val(),
operation_type_id: $('#diffact_type_id').val(),
description: $('#description').val(),
if($('#FaturaDurum').is(":checked"))
{
document.getElementById('FaturaDurum').value = "1"
}
else
{
document.getElementById('FaturaDurum').value = "0"
}
FaturaDurum: $('#FaturaDurum').val()
})
Backend;
if($request->input('FaturaDurum') == "1")
{
$faturadurum = 'Faturalandirilmamis';
}
else
{
$faturadurum = 'Faturalandirilmis';
}
According to the checkbox information I received from the frontend, I will record to the database in the backend. I am stuck in the part where I wrote in bold, please help.
CodePudding user response:
I think it's better to write the code like this:
someValue : $('#FaturaDurum').is(":checked") ? document.getElementById('FaturaDurum').value = "1" : document.getElementById('FaturaDurum').value = "0"
CodePudding user response:
I suggest using the following code:
let faturaDurum = document.getElementById('FaturaDurum');
someValue : $('#FaturaDurum').is(":checked") ? faturaDurum.value = "1" : faturaDurum.value = "0"