Reputation: 12957
Following is my code snippet:
<tr height="30" id="user_option">
<td width="300">
<input type="checkbox" id="users" name="users" value="users"/>Users
</td>
<td> <input type="checkbox" id="upload_from_file" name="upload_from_file" value="upload_from_file"/>Upload From File
</td>
<td>
<input type="checkbox" id="copy_paste_from_excel" name="copy_paste_from_excel" value="copy_paste_from_excel"/>Copy paste from excel
</td>
</tr>
This is a code from smarty template. Actually when I submit this form I want an array containing the checkbox values so in order to achieve that I have to use same name for these checkboxes. But I'm not able to name thes checkboxes in such a manner that I could get all the selected checkboxes' value in one single array after form submission. Can you help me in achieving this? Thanks in advance.
Upvotes: 0
Views: 95
Reputation: 2212
Define the name attribute of checkboxes to be an array:
<input type="checkbox" id="id1" name="cb_data[var_name1]" value="some_val"/>
<input type="checkbox" id="id2" name="cb_data[var_name2]" value="another_val"/>
then check the $_POST['cb_data']
array.
Upvotes: 1