展开全部
楼主是想要点击合计就是出数值还是什么?如果说点击合计就算出值的话如下
<table width="400" border="1">
<tr>
<th rows="5">简易购物车</th>
</tr>
<tr>
<td>商品名称</td>
<td>数量(件)</td>
<td>单价(美元)</td>
<td>运费(美元)</td>
<td><button onclick="fun()">合计</button></td>
</tr>
<tr>
<td><input type="text" name="goodsName" /></td>
<td><input type="text" name="num" id="num" /></td>
<td><input type="text" name="price" id="price" /></td>
<td><input type="text" name="freight" id="freight" /></td>
<td><input type="text" name="total" id="total" /></td>
</tr>
</table>
<script>
function fun(){
var num = document.getElementById("num").value;
var price = document.getElementById("price").value;
var freight = parseInt(document.getElementById("freight").value);
var total = (price * num) + freight;
document.getElementById("total").value = total;
}
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询