jeudi 5 janvier 2017

Checkbox Php : Keep checked only the checked checkbox after submitting Get form

This is my code

<?php foreach ($categories as $cat) {  ?>
    <li>
    <input id="category" name="category[]"  type="checkbox" value="<?= $cat->term_id; ?>" 
    <?php if (isset($_GET['category'])) echo "checked='checked'"; ?>><?= $cat->name ?></input>
    </li>
<?php } ?>

image 1 But when i submit the form the check boxes are all checked and what i wan't is to keep checked only the checkbox i checked not the others Example Below image 2




Aucun commentaire:

Enregistrer un commentaire