我有一个显示MySQL查询结果的PHP页面。 用户可以通过点击Get Total
按钮来改变预期的输入量,用户可以看到Item Rate * Qty Intended
的结果。因此,total
可用于为用户创建优惠券。计算速率*数量的动态值
任何人都可以指导我如何将此功能添加到我现有的页面。
我的代码当前如下所示:
<?php
include 'functions.php'; //for connection
?>
<table>
<tr>
<th>Select</font></th>
<th>Item Desc</th>
<th>Item Specification</th>
<th>Item Rate</th>
<th>Qty Intented</th>
</tr>
<?php
$sql1 = mysql_query("SELECT * from item
where item ='stationeries'")
while ($row = mysql_fetch_array($sql1, MYSQL_ASSOC)) {
?>
<tr>
<td><input type="checkbox" name="sel" /></td>
<td><?php echo $row['item']; ?></td>
<td><?php echo $row['specification']; ?></td>
<td><?php echo $row['rate']; ?></td>
<td><input type="text" name="qty" class="toAdd" id="qty" value="0.0" /></td>
</tr>
<?php
}
?>
</table><br />
<input type="button" value="Get Total" />
<input type="text" id="total" />
则需要使用JavaScript来乘3号元素的两个值和地点 – DevZer0
你希望有人来指导你或为你编码?因为这是非常基本的JavaScript ... –