php - How to get checked inputs from HMTL5 table -
i know if has idea on how checked values of radio-buttons. there 5 columns , several rows, user can select 1 radio-button per column.
i have been trying values haven't been able through jquery, or sending through post php file.
<table class="table table-striped table-hover " id='tableincoming'> <thead> <tr> <th>#</th> <th>route</th> <th>monday</th> <th>tuesday</th> <th>wednesday</th> <th>thursday</th> <th>friday</th> </tr> </thead> <tbody> {section name=lindex loop=$incoming_list} <tr style="" class="{if $incoming_list[lindex].name eq 'tres rios' || $incoming_list[lindex].name eq 'cartago'}info{/if}" id="tr{$incoming_list[lindex].name}-{$incoming_list[lindex].time}"> <td>{$smarty.section.lindex.index +1}</td> <td style="width:220px;"> {$incoming_list[lindex].name}, {$incoming_list[lindex].time} </td> <td><input name="m" type="radio"></td> <td><input name="t" type="radio"></td> <td><input name="w" type="radio"></td> <td><input name="th" type="radio"></td> <td><input name="f" type="radio"></td> </tr> {/section} <tr style="" class="" id='trwnui'> <td>-</td> <td style="width:220px;" name='wnui'>will not use</td> <td><input name="m" type="radio"></td> <td><input name="t" type="radio"></td> <td><input name="w" type="radio"></td> <td><input name="th" type="radio"></td> <td><input name="f" type="radio"></td> </tr> </tbody> </table>
solution @lennon, updated table provide values, here how code looks now:
{section name=lindex loop=$incoming_list} <tr style="" class="{if $incoming_list[lindex].name eq 'tres rios' || $incoming_list[lindex].name eq 'cartago'}info{/if}" id="tr{$incoming_list[lindex].name}-{$incoming_list[lindex].time}"> <td>{$smarty.section.lindex.index +1}</td> <td style="width:220px;"> {$incoming_list[lindex].name}, {$incoming_list[lindex].time} </td> <td><input name="mi[]" value='i, m, {$incoming_list[lindex].name}, {$incoming_list[lindex].time}' type="radio"></td> <td><input name="ti[]" value='i, t, {$incoming_list[lindex].name}, {$incoming_list[lindex].time}' type="radio"></td> <td><input name="wi[]" value='i, w, {$incoming_list[lindex].name}, {$incoming_list[lindex].time}' type="radio"></td> <td><input name="thi[]" value='i, th, {$incoming_list[lindex].name}, {$incoming_list[lindex].time}' type="radio"></td> <td><input name="fi[]" value='i, f, {$incoming_list[lindex].name}, {$incoming_list[lindex].time}' type="radio"></td> </tr> {/section}
you have use brackets on name of radio buttons. when submit them, php recognize array.
example here: multiple radio button array php form
this:
<tr style="" class="{if $incoming_list[lindex].name eq 'tres rios' || $incoming_list[lindex].name eq 'cartago'}info{/if}" id="tr{$incoming_list[lindex].name}-{$incoming_list[lindex].time}"> <td>{$smarty.section.lindex.index +1}</td> <td style="width:220px;"> {$incoming_list[lindex].name}, {$incoming_list[lindex].time} </td> <td><input name="m" type="radio"></td> <td><input name="t" type="radio"></td> <td><input name="w" type="radio"></td> <td><input name="th" type="radio"></td> <td><input name="f" type="radio"></td> </tr>
need this:
<tr style="" class="{if $incoming_list[lindex].name eq 'tres rios' || $incoming_list[lindex].name eq 'cartago'}info{/if}" id="tr{$incoming_list[lindex].name}-{$incoming_list[lindex].time}"> <td>{$smarty.section.lindex.index +1}</td> <td style="width:220px;"> {$incoming_list[lindex].name}, {$incoming_list[lindex].time} </td> <td><input name="m[]" type="radio"></td> <td><input name="t[]" type="radio"></td> <td><input name="w[]" type="radio"></td> <td><input name="th[]" type="radio"></td> <td><input name="f[]" type="radio"></td> </tr>
and access through $_post['m']['id_of_checked_item']