mercredi 13 avril 2016

How to get value of an input (checkbox input) in auto generated forms that displayed as table rows?

I generate table from database, assign each cell as checkbox value, group each row as form and display them all as table refer to [this].1 How I can get particular cell value when i click on the button since each form (row) have a same id. I want to pass the value as query parameter to update the database table. I have searched for similar technique and still not find the solution.

This code is within a cursor fetching loop:

                            <form class="tr" id="barisn" method="post" action="">
                                        <span class="td"><input type="checkbox" name="id" value="<?php $data[0]?>"/><label for="id"><?php echo $data[0]?></label></span>
                                        <span class="td"><input type="checkbox" name="name" value="<?php $data[1]?>" /><label for="name"><?php echo $data[1]?></label></span>
                                        <span class="td"><input type="checkbox" name="gender" value="<?php $gender?>" /><label for="gender"><?php echo $gender?></label></span>
                                        <span class="td"><input type="checkbox" name="sender" value="<?php $data[8]?>" /><label for="sender"><?php echo $data[8]?></label></span>
                                        <span class="td"><input type="checkbox" name="date" value="<?php $data[5]?>" /><label for="date"><?php echo $data[5]?></label></span>
                                        <span class="td"><input type="checkbox" name="time" value="<?php $data[6]?>" /><label for="time"><?php echo $data[6]?></label></span>
                                        <span class="td"><input type="checkbox" name="state" value="<?php $state?>" /><label for="state"><?php echo $state?></label></span>
                                        <div class="td">
                                                <button class="btn-rawuh" type="submit" form="barisn" value="Rawuh">Rawuh</button>
                                                <button class="btn-tundha" type="submit" form="barisn" value="Tundha">Tundha</button>
                                                <button class="btn-mlebet" type="submit" form="barisn" value="Mlebet">Mlebet</button>
                                        </div>
                                </form>

The point is I still can not find a method to indexing row as user may click a button in it. Table result:




Aucun commentaire:

Enregistrer un commentaire