dimanche 10 juin 2018

PHP form multiple checkbox groups

I have a group of checkboxes in a from and I need to get values with php. Note that div class="group" can also be duplicated onruntime (with jquery) so I may end with multiple div class="group" of checkboxes.

Is there a way to set checkboxes name so form data gets grouped together for each "group", or whatever is easier to handles afterwards? There is also a problem of checkboxes that were not checked, so they wont be present in a post data.

I tried using names like this but I dont like the results.

<form>
    <div class="group">
        <input type="checkbox" name="ev[][time]">
        <input type="checkbox" name="ev[][space]">                 
        <input type="checkbox" name="ev[][money]">
    </div>

    <div class="group">
        <input type="checkbox" name="ev[][time]">
        <input type="checkbox" name="ev[][space]">                 
        <input type="checkbox" name="ev[][money]">
    </div>
</form>




Aucun commentaire:

Enregistrer un commentaire