I have multiple checkboxes that gets generated and the user should be able to check/uncheck the box and be able to change the checkbox state again. The problem I'm facing is that onchange will only work when the user changes the checkbox, but if it's already checked and the user saves without interaction, the checked box will be reset to unchecked.
I'm not really good with javascript but I guess I would need to change the "onchange" to something else to run the js part whether the user interacts with the checkbox or not?
<!-- Some code to loop through each object in the row -->
<input type="hidden" name="object[]" value="0"><input type="checkbox" onchange="this.previousSibling.value=1-this.previousSibling.value"
<?php
if (isset($row['object'])) {
if ($row['object'] == 1) {
echo " checked"
}
}
?>
>
Aucun commentaire:
Enregistrer un commentaire