<input name=w1>+
<input name=w2>+
<input name=w3>
<input type=button value="=" onclick="document.all.w4.value=parseInt(document.all.w1.value)+parseInt(document.all.w2.value)+parseInt(document.all.w3.value)">
<input name=w4>
<input name=w2>+
<input name=w3>
<input type=button value="=" onclick="document.all.w4.value=parseInt(document.all.w1.value)+parseInt(document.all.w2.value)+parseInt(document.all.w3.value)">
<input name=w4>
<head>
<script>
function calc(frm){
try{
var result = parseFloat(frm.w1.value);
result += parseFloat(frm.w2.value);
result += parseFloat(frm.w3.value);
document.all('result').value = result;
}
catch(e){
alert(e.description);
}
}
</script>
</head>
<body>
<form name="form1">
w1:<input name="w1" type="text" value=""><br>
w2:<input name="w2" type="text" value=""><br>
w3:<input name="w3" type="text" value=""><br>
</form>
结果:<input id="result" type="text" value="">
<button onclick="calc(document.form1);">计算</button>
</body>
</html>