Step 1: On clicking a button, show a modal.
<button class="btn btn-sm fa fa-edit" onclick="updateJobModal('<?php echo $custContactName ?>','<?php echo $jobDesc ?>','<?php echo $detailedDesc ?>','<?php echo $poNumber ?>','<?php echo substr($dueDate, '0', '10') ?>','<?php echo $prevJobNumber ?>','<?php echo $totalSellPrice ?>','<?php echo $sellLevel ?>','<?php echo $brandType ?>','<?php echo $clientRef ?>')"> </button>
JavaScript:
const updateJobModal = (contact, jdesc, detailed, pono, duedate, prevjob, total, selllevel, brand, cliref) => {
let recordInUse = <?php echo $recordInUse?>;
if (recordInUse === 1) {
swal('Error', 'Unable To Update! Job Is Currently Open In EPMS!!', 'warning');
} else {
console.log([contact, jdesc, detailed, pono, duedate, prevjob, total, selllevel, brand, cliref]);
document.getElementById('jobdesc').value = jdesc;
document.getElementById('contact').value = contact;
document.getElementById('contact').innerText = contact;
$('#ddesc').val(detailed);
$('#ponumber').val(pono);
$('#duedate').val(duedate);
$('#prevno').val(prevjob);
$('#totalprice').val(total);
$('#selllevel').val(selllevel);
$('#brand').val(brand);
$('#clientref').val(cliref);
$('#modal-form').modal('show');
}
};
Now the problem is the field $detailedDesc
has commas in it. Example:
Lot B--Box , Blank Tray , Top Insert, Mailing Label
It breaks the function and causes Uncaught SyntaxError: Invalid or unexpected token
.
Function call causing the error:
updateJobModal('','Snack Pack Custom Box Mailing','Lot B--Box , Blank Tray , Top Insert, Mailing Label
','Array','2018-07-31','','235315','20/30','Brand','Client Ref')
How do I get it to working correctly?