I am having trouble with passing multiple variables into on jQuery function (jQuery v3.6.1)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
function takeId(newButtonId, startTime, endTime, date, note){
$('#myModal').modal('show');
try {
$('#bookingIdHidden').attr('value', newButtonId);
$('#timeStart').attr('value', startTime);
$('#timeEnd').attr('value', endTime);
$('#date').attr('value', date);
$('#note').attr('value', note);
} catch(err) {
alert(err);
}
};
For some reason this does not work (function does not run at all), however it does work when I only pass in one value and only set the value of #bookingIdHidden
This function is called using onclick() from a button, here:
<input type='button' name='edit' value='Edit' onclick="takeId($newButtonId, $startTime, $endTime, $date, $note);" id='1'>
Echo Version
echo "<td>" . "<input type='button' name='edit' value='Edit' onclick='takeId($newButtonId, $startTime, $endTime, $date, $note)' id='1'>" . "</td>";
<input type="button" name="edit" value="Edit" onclick="takeId(1," 06:00:00.0000,="" 07:00:00.0000,="" 2023-01-05,="" ,="" 0)="" id="1">
Would anyone know why?
All help will be much appreciated