我正在使用bootstrap表.我希望Item ID在单击'Add to cart'同一页面上的按钮后获取所选表行的值/值.
表格代码:
<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>
Run Code Online (Sandbox Code Playgroud)
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';
});
});
Run Code Online (Sandbox Code Playgroud)
因为我是bootstrap的新手,我正试图解决这个问题,但没有得到适当的解决方案,任何人请告诉我这个.
如上所述,我试图在我的 PHP 脚本中获取用户输入以执行进一步的任务。PHP 中是否有任何方法来获取用户输入,例如 C 中使用的“scanf()”
<?php
echo "Swapping Numbers </br> Please select the method: </br>";
echo "1. Using 3rd variable </br> 2. Using add/sub </br> 3. Using mul/div";
//read user input $choice
switch($choice)
{
case 1:
break;
case 2:
break;
case 3:
break;
default:
echo "</br>You entered wrong choice";
}
?>
Run Code Online (Sandbox Code Playgroud)