jeudi 12 novembre 2015

How do I attach checkboxes to a submit

I have unknown amount of checkbox inputs on a page created based on rows in an sql database.

The checkboxes look like:

<input type="checkbox" class="deletefunc" value="<? echo $mid; ?>">

The checkboxes are intended, when checked and submitted, to delete a row from the database based on the value of $mid

The checkboxes could be either loose (not contained in any forms), or each could be contained in its own form (without a submit button). There is no way however to contain all the checkboxes in one form.

The reason is it's displayed in a loop with output like this:

<tr>
<td><input type="checkbox" class="rowfuncs" value="<? echo $mid; ?>"></td>
<td><input type="checkbox" class="star" value="1"> <!-- jquery/ajax onclick function --></td>
<td><a href></td>
<td><form name....><input type="submit" value="something"></form></td>
<tr>

So what I need help understanding is, how to gather all the checkboxes based on classname, and attach them to a submit button....

And further, how would I write the loop function so it knows how many deletes to perform? What I mean is, how would I write a loop that would get the values from an unknown amount of inputs. Normally I know how many inputs there are and what the names are so its a matter of assigning a variable for each input.... I've never done this with an unknown amount of inputs.




Aucun commentaire:

Enregistrer un commentaire