我正在使用引導程序表。在這裏我想在點擊'Add to cart'
按鈕出現在同一頁面後獲得所選表格的Item ID
值/值。使用jquery獲取引導程序中選定錶行的值
表代碼:
<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-請參閱我編輯的問題。 –
對不起,再一次,你可以確定表格行的HTML結構,想看看如何HTML呈現。只需幾行就行了 –