jeudi 27 octobre 2016

Can't get checkbox to update on refresh

I have a form with a checkbox. When saved to the db it has 2 possible states: if checked it is "on" otherwise the field is empty. A similar form is presented for editing a row from the db. It allows the user to make changes and then review them before submitting an update to the db. At the moment, all other fields (text and radio sets) reflect the changes when the page is refreshed through a submit button. However, the checkbox doesn't retain the update to checked or unchecked.

my code:

<td><input type='checkbox' name = 'reg' id = 'reg' value =  
'".$_POST['reg']."' ".($_POST['reg'] == 'on' ? 
'checked="checked"' : '')."/></td>

I can show more code if it helps - I thought this was the portion that needed repair.




Aucun commentaire:

Enregistrer un commentaire