Answer the question
In order to leave comments, you need to log in
How to make a JS function call when checking a php post request?
I have a checkbox, I need it to keep its status (checked or not) after sending POST.
This is my code, the condition works but the function call doesn't. Perhaps there is an error somewhere?
<input class="checkboxDiv_input" type="checkbox" name="checkbox_work" value="Yes" id="checkbox_work" onclick="checkAddress(this)">
<?php
if(isset($_POST['checkbox_work'])){
if($_POST['checkbox_work'] == 'Yes'){
echo '<script type="text/javascript"> checkAddress("checkbox_work"); </script>';
}
}
?>
<script>
function checkAddress(checkbox)
{
if (checkbox.checked)
{
$('#endWork').attr('disabled',true);
} else{
$('#endWork').attr('disabled',false);
}
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question