因为我在php中做一个stockmanagement应用程序系统。因为我有很多与产品相关的按钮..我想得到按钮ID并想在数据库中进行更改...我没有得到我的按钮ID请帮帮我......
<button class="btn btn-primary btn-lg" id=100 onclick="rowAdding(0)">Pizza - $20</button>
<button class="btn btn-primary btn-lg" id=101 onclick="rowAdding(1)">Burger - $30</button>
<button class="btn btn-primary btn-lg" id=102 onclick="rowAdding(2)">Springroll - $25</button>`
这里我试图获取我的buttonid并做一些脚本
if(isset($_REQUEST['button'])){
echo"Authenticating";
$buttonnumber = array_pop(array_keys($_REQUEST['button']));
$buttonvalue = array_pop($_REQUEST['button']);
}else{
echo "Not Updated into database";
}
这里有函数rowAdding()脚本......
function rowAdding(index,qty){
if(typeof qty == 'undefined')
qty=1;
if(products[index][2]<=0){
products[index][2]=1;
products[index][3]=(products[index][1] * products[index][2]);
var row = $("<tr id='product"+index+"'>");
row.append($("<td>"+products[index][0]+"</td>"))
.append($("<td>$"+products[index][1]+"</td>"))
.append($("<td><button onclick='rowAdding("+index+",-1)'>-</button> <span id='product_qty"+index+"'>"+products[index][2]+"</span> <button onclick='rowAdding("+index+",1)'>+</button></td>"))
.append($("<td id='product_amount"+index+"'>$"+products[index][3]+"</td>"))
$("#myTable tbody").append(row);
}else{
products[index][2]+=qty;
if(products[index][2]<=0){
products[index][2]=0;
products[index][3]=0;
$("#product"+index).remove();
}else{
products[index][3]=(products[index][1] * products[index][2]);
$("#product_qty"+index).html(products[index][2]);
$("#product_amount"+index).html("$"+products[index][3]);
}
}
var totalAmount=0;
for(var i=0;i<products.length;i++){
totalAmount+=products[i][3];
}
$("#total_amount").html("$"+totalAmount);
}