[英]Is there a way I could store id of my button used in a table?
<?php
while($row = mysqli_fetch_array($results)){
?>
<tbody>
<tr>
<td> <?php echo $row['Product_ID'] ?></td>
<td> <?php echo $row['Product_Name'] ?></td>
<td> <?php echo $row['Product_Price'] ?></td>
<td> <?php echo $row['Product_Stock'] ?></td>
<td> <button type="submit" name="add" id="<?php $row['Product_ID'] ?>" onclick="func(<?php $row['Product_ID'] ?>)"> Add </button></td>
</tr>
<?php } ?>`
<script type="text/javascript" method="post">
function func(id){
window.alert(id);
};
</script>
Is there a way I could store id of my button named add? 有没有一种方法可以存储名为add的按钮的ID? I've to store multiple product ids and use them in a receipt that would be generated using product ids.
我必须存储多个产品ID,并在使用产品ID生成的收据中使用它们。 the method of the form is
POST
but I don't know how to get the id 表单的方法是
POST
但我不知道如何获取ID
Replace this 取代这个
func(<?php $row['Product_ID'] ?>)
With This 有了这个
func(<?php echo $row['Product_ID']; ?>)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.