[英]How to get value table row value using jquery/ajax
<?php
include "config.php";
// Fetch the data
$con = mysql_query("select * from product");
?>
<div style=" height:250px; overflow:auto;">
<table class="table table-striped table-bordered dTableR" id="ajxtable">
<tr>
<th>Jobno</th>
<th>Product</th>
<th>Qty</th>
<th>Designed by</th>
<th>Action</th>
</tr>
<?php
while ($row = mysql_fetch_array($con)) {
$id = $row['id'];
$pcode = $row['pcode'];
$lproduct = $row['lproduct'];
$mrprate = $row['mrprate'];
?>
<tr>
<td><?php echo $id; ?></td>
<td><?php echo $lproduct; ?></td>
<td><?php echo $mrprate; ?></td>
<td><?php echo "admin"; ?></td>
<td><input type="button" id="addmorePOIbutton1" style="width:25px;" value="+" onClick=""/>
<input type="button" id="delPOIbutton1" style="width:25px;" value="-" onClick=""/></td>
</tr>
<?php
}
?>
</table>
</div>
This is ajax page. 这是ajax页面。 Below table is auto refreshed every 5 seconds. 下表每5秒自动刷新一次。
My doubt is how to get that particular row value. 我的疑问是如何获取特定的行值。
When i click table row + button, get these particular row values, and place to index page text box and this '+' button also hide. 当我单击表行+按钮时,获取这些特定的行值,并将其放置到索引页文本框中,并且此“ +”按钮也会隐藏。
Kindly suggest any jquery or ajax code for adding below code. 请建议添加以下代码的任何jquery或ajax代码。
I am new to jquery ,,anybody help me with sample code..that would help me greately. 我是jquery的新手,任何人都可以通过示例代码来帮助我。这将极大地帮助我。 Thanks in advance 提前致谢
$(document).ready(function () {
$('#yourtablename tr').click(function (event) {
alert($(this).attr('id')); //trying to alert id of the clicked row
});
});
Above code may be help you and another solution is: 上面的代码可能会对您有所帮助,另一个解决方案是:
$('td').click(function(){
var row_index = $(this).parent().index();
var col_index = $(this).index();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.