I want to calculate total amount when I change quantity
我希望在更改数量时获得总金额。
此脚本在while循环中不起作用:(quantity * amount = total_amount)
我该如何解决这个问题? 请帮我解决这个问题。
1 2 3 4 5 6 | function calculateTotal() { var totalAmt = document.addem.total.value; totalR = eval(totalAmt * document.addem.tb1.value); document.getElementById('total_amount').innerHTML = totalR; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <table> <tr> <td>Id</td> <td>Product</td> <td>Quantity</td> <td>Total</td> </tr> <tr> <?php $sq=mysql_query("select * from cart_sample where email='$ema'"); while($row = mysql_fetch_array($sq)) { ?> <td><?php echo $row['id']; ?></td> <td><?php echo $row['product']; ?></td> <form name="addem" id="addem" /> <td><input type="text" name="tb1" onkeyup="calculateTotal()" value="<?php echo $row['quantity']; ?>" /></td> <input type="hidden" name="total" value="<?php echo $row['amount']; ?>" /> <td><span id="total_amount"></span></td> <?php } ?> </tr> </table> |