I have some checkboxes in an array generated dynamically using a while loop like in the code below. When the checkbox(es) are checked and the form submitted, the value is passed to a PHP variable. However, after the form is submitted and the page loads, the checkboxes do not remain checked. How do I make it so that they stay checked after the form is submitted and the page reloads?
...
<form method="POST">
<input type="checkbox" name="checkArr[]" value="2">
<input type="checkbox" name="checkArr[]" value="6">
<input type="checkbox" name="checkArr[]" value="1">
<input type="checkbox" name="checkArr[]" value="11">
<input type="submit" name="submit-form">
</form>
...
<?php
if (isset($_REQUEST['submit-form']) && isset($_REQUEST['checkArr'])) {
$checkedNumbers = implode(',', $_REQUEST['checkArr']);
}
?>
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire