gpt4 book ai didi

javascript - 如何使用Jquery获取记录表并使用AJAX将其发送到服务器?

转载 作者:行者123 更新时间:2023-12-03 03:18:03 24 4
gpt4 key购买 nike

我有一个如下表

<table cellspacing="0" rules="all" border="1" id="ContentPlaceHolder1_GridView1" style="border-collapse:collapse;" class="table table-striped">
<tbody>
<tr>
<th scope="col">&nbsp;</th>
<th scope="col">Bill NO</th>
<th scope="col">Date</th>
<th scope="col">Description</th>
<th scope="col">Type</th>
<th scope="col">Amount</th>
</tr>
<tr>
<td><input id="Checkbox0" class="checkBoxClass" type="checkbox">/td>
<td>111</td>
<td>12-22-2014</td>
<td>computer problem</td>
<td>Invoice</td>
<td class="ActualAmount">7689.00</td>
</tr>
<tr>
<td><input id="Checkbox1" class="checkBoxClass" type="checkbox">/td>
<td>112</td>
<td>12-22-2014</td>
<td>Printer problem</td>
<td>Invoice</td>
<td class="ActualAmount">7689.00</td>
</tr>
</tbody>
</table>

如果在该行上选中了复选框,我将尝试获取 BillNoActualAmount 的值

首先,我尝试使用下面的代码获取行的值

alert('value = ' + $("#ContentPlaceHolder1_GridView1 .checkBoxClass input[type='checkbox']:checked").closest("td").val())

它警报 值=未定义

我正在尝试获取这样的值 Jfiddle

最佳答案

如果您想获取选中该复选框的所有行并将该值保存在对象数组中...

var values = [];

$('table#ContentPlaceHolder1_GridView1 input.checkBoxClass:checked').each(function() {
var $row = $(this).closest('tr').children('td');
values.push({ 'billno': $row.eq(1).text(), 'amount': $row.eq(5).text() });
});

希望对你有帮助

关于javascript - 如何使用Jquery获取记录表并使用AJAX将其发送到服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46682504/

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