gpt4 book ai didi

javascript - 如何使用jquery/ajax获取值表行值

转载 作者:行者123 更新时间:2023-11-28 08:09:53 25 4
gpt4 key购买 nike

<?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>

这是ajax页面。下表每 5 秒自动刷新一次。

我的疑问是如何获取该特定行值。

当我单击表行 + 按钮时,获取这些特定的行值,并将其放置到索引页文本框,并且此“+”按钮也会隐藏。

请建议任何 jquery 或 ajax 代码来添加以下代码。

我是 jquery 新手,任何人都可以帮助我提供示例代码..这会对我有很大帮助。提前致谢

最佳答案

$(document).ready(function () {      
$('#yourtablename tr').click(function (event) {
alert($(this).attr('id')); //trying to alert id of the clicked row

});
});

上面的代码可能对您有帮助,另一个解决方案是:

 $('td').click(function(){
var row_index = $(this).parent().index();
var col_index = $(this).index();
});

关于javascript - 如何使用jquery/ajax获取值表行值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24361695/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com