lundi 17 août 2015

keeping checkbox unchecked/checked(according to input value) after validation fail

I am trying to restore the value after validation if box is checked/unchecked

If I am selecting the checkbox, after validation fails it will remain checked, but when I am submitting without selecting the checkbox, it still remains checked. I want to make that unchecked instead.

<label>
    <span>Free Enrty:</span> 
    <input type="checkbox" name="free_check"  style="margin-top: 10px;" value="1" <?php if($_POST['free_check']==0) echo "checked='checked'"; ?>  />(Check if entry is free)
</label>




Aucun commentaire:

Enregistrer un commentaire