楼主是想要点击合计就是出数值还是什么?如果说点击合计就算出值的话如下
<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>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head>
<title>MyHtml2.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/htmlcharset=UTF-8">
<script>
/*
*@author Caoshun
*@计算 合计费用
*/
function countMethod(){
var num=document.getElementById("num").value
var unitPrice=document.getElementById("unitPrice").value
var freight=document.getElementById("freight").value
document.getElementById("result").value=parseFloat((num*unitPrice))+parseFloat(freight)
}
</script>
</head>
<body>
<table border="1" cellpadding="1" cellspacing="1" background="#red" style="text-align: center">
<tr><td colspan="5" align="center">简易购物车</td></tr>
<tr>
<td>商品名称</td>
<td>数量(件)</td>
<td>单价(美元)</td>
<td>运费(美元)</td>
<td><input type="button" value="合计" onclick="countMethod()"></td>
</tr>
<tr>
<td>跑跑道具</td>
<td><input type="text" size="6" id="num"></td>
<td><input type="text" size="6" id="unitPrice"></td>
<td><input type="text" size="6" id="freight"></td>
<td><input type="text" size="6" id="result"></td>
</tr>
</table>
</body>
</html>