简体   繁体   English

根据所选复选框获取表行数据

[英]Fetch table row data as per the selected checkbox

I am using Material Design Lite to create a table and I am inserting rows dynamically using php. 我正在使用Material Design Lite创建表,并且正在使用php动态插入行。 The material design lite has provided checkboxes for each row. 物料设计Lite已为每一行提供了复选框。 Now, I want to use the selected row's data on a button click. 现在,我要在单击按钮时使用所选行的数据。 Does anyone have any idea how to do that? 有谁知道如何做到这一点?

Here is the code : 这是代码:

<table class="mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--2dp" id="sanctionedTable">
<thead>
<tr>
  <th class="mdl-data-table__cell--non-numeric">Name</th>
  <th class="mdl-data-table__cell--non-numeric">Registration No.</th>
  <th class="mdl-data-table__cell--non-numeric">Amount</th>
</tr>
</thead>
<tbody>
<?php 
$temp = "";
  while($row = mysqli_fetch_assoc($result))
  {
    $temp="<tr><td>".$row["name"]."</td><td>".$row["regno"]."</td><td>".$row["amount"]."</td></tr>";
    echo $temp;
  }
?>
</tbody>
</table>

You can use something like this using jquery: 您可以使用jquery使用类似的方法:

$('tr').click(function(){

alert("Name:"+$(this).children('td:nth-child(1)').html()+",Registration nio:"+$(this).children('td:nth-child(2)').html()+",Amount:"+$(this).children('td:nth-child(3)').html());
});

This fetches the information in each row. 这将获取每一行中的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM