lundi 3 février 2020

Save dynamically created checkbox ID in PHP and Ajax

Here in my application the check boxes in the form are dynamically created using foreach loop. The name and ID also dynamically created. When I use same ID or name the check box is not working according to my web template.

Here I can't understand how to get the IDs and names of each check box and pass the IDs and names to Ajax call.

<?php
    $i = 0;
    if (is_array($tests) || is_object($tests)) {
        foreach ($tests as $value) {
            $i++;
            ?>

            <h5>
                <?php echo $value; ?>
                <span>
                    <input type="checkbox" class="filled-in" id="filled-in-box-<?php echo $i; ?>" />
                    <label for="filled-in-box-<?php echo $i; ?>"></label>
                </span>
            </h5>

            <span class="sdn-hall-na">Apj Hall 112</span>

            <?php
        }
    }
?>

Please help me.




Aucun commentaire:

Enregistrer un commentaire