0
<a href="printable.php">
<button id="btnSubmit" type="button" class="btn btn-primary" disabled="disabled">Print</button>
<a>
<script> 
        if ($verifikasi = "Pending") {
            //Disable the TextBox when TextBox has value.
            btnSubmit.disabled = true;
        } else {
            //Enable the TextBox when TextBox is empty.
            btnSubmit.disabled = false;
        }
</script>

I'm trying to disable Print Button if the status($verifikasi) is still "Pending", but the button is still clickable.

  • 1
    You need to use `==` instead of `=` when comparing values – flyingfox Mar 25 '23 at 09:16
  • You’re also using ```disabled=“disabled”``` and ```disabled=true/false``` https://stackoverflow.com/questions/3014649/how-to-disable-html-button-using-javascript#3014678 And are you sure the button on click is triggered or is it the anchor? How do you get the reference to the button? Show more code please. – davsto Mar 25 '23 at 09:20

1 Answers1

1

You need to use == instead of = when comparing values

So change $verifikasi = "Pending" to $verifikasi == "Pending"


Working demo

$verifikasi = "notPending"
if ($verifikasi == "Pending") {
    //Disable the TextBox when TextBox has value.
    btnSubmit.disabled = true;
} else {
    //Enable the TextBox when TextBox is empty.
    btnSubmit.disabled = false;
}
<a href="printable.php">
<button id="btnSubmit" type="button" class="btn btn-primary" disabled="disabled">Print</button>
<a>
flyingfox
  • 13,414
  • 3
  • 24
  • 39