<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>简易购物车</title>
<script type="text/javascript">
function sum()
{
var num=parseInt(document.table.num.value);
var price=parseInt(document.table.price.value);
var cost=parseInt(document.table.cost.value);
var amount=num*price+cost;
document.table.amount.value=amount;
}
</script>
</head>
<body>
<table border=1>
<tr>
<th colspan=5>简易购物车</th>
</tr>
<tr>
<td>商品名称</td>
<td>数量(件)</td>
<td>单价美元</td>
<td>运费(美元)</td>
<td><input type ="submit" value="合计" onclick="sum()"/></td>
</tr>
<tr>
<td>跑跑道具</td>
<td ><input type="text" name="sum"/></td>
<td><input type="text" name="price"/></td>
<td><input type="text" name="cost"/></td>
<td><input type="text" name="amount"/></td>
</tr>
</table>
</body>
</html>
我不知道怎么取出文本框里的数据然后加起来
然后谷歌调试报错是说num未定义