【发布时间】:2015-11-15 01:51:56
【问题描述】:
我正在使用引导表。我想在单击同一页面上的'Add to cart' 按钮后获取所选表行的Item ID 值/值。
表格代码:
<table data-toggle="table" id="table-style" data-row-style="rowStyle" data-url="tables/data2.json" data-show-refresh="true" data-show-toggle="true" data-show-columns="true" data-search="true" data-select-item-name="toolbar1" data-pagination="true" data-sort-name="name" data-sort-order="desc" data-single-select="false" data-click-to-select="true" data-maintain-selected="true">
<thead>
<tr>
<th data-field="state" data-checkbox="true"></th>
<th data-field="id" >Item ID</th>
<th data-field="name" data-sortable="true">Product Name</th>
<th data-field="price" data-sortable="true">Actual Price</th>
<th data-field="discount_price" data-sortable="true">Discount Price</th>
<th data-field="stock_avail" data-sortable="true">Stock Available</th>
</tr>
</thead>
</table>
JQuery 代码:
$(document).ready(function()
{
$("#add_cart").click(function()
{
//foreach selected row retrieve 'Item ID' values in array;
//call ajax for otherpage.php?arr='Item ID array';
});
});
由于我是引导程序的新手,我正在尝试解决这个问题,但没有得到适当的解决方案,请任何人告诉我这个。
【问题讨论】:
-
tr td数据是什么样的? -
@NorlihazmeyGhazali-请查看我编辑的问题。
-
Opss 抱歉,再一次,你能确定表格行的 HTML 结构吗,想看看 HTML 是如何呈现的。几行就够了
-
@NorlihazmeyGhazali- 我使用引导表插件作为表。
标签: javascript jquery twitter-bootstrap bootstrap-table