A
A
ArtJH2019-08-24 12:39:23
PHP
ArtJH, 2019-08-24 12:39:23

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

1 answer(s)
V
vism, 2019-08-24
@vism

Wrap your shitty code in a ready document and it will work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question