我正在使用此代码来计算 2 个字段的乘积并且有很多行,当我只使用一行时,结果将打印在输入字段中。但是当我使用多行输入字段时,结果不会打印到文本框中......我怎么能这样?
代码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function updatesum() {
document.input.total.value = (document.input.time.value -0) * (document.input.cost.value -0);
return false;
}
</script>
</head>
<body>
<form name="input" action="#" method="post" onsubmit="return false;">
Timespent:<input type="text" name="time" value=" ">
Cost:<input type="text" name="cost" value=" ">
Totalcost:<input type="text" name="total" value=" ">
<br>
Timespent:<input type="text" name="time" value=" ">
Cost:<input type="text" name="cost" value=" ">
Totalcost:<input type="text" name="total" value=" ">
<br>
Timespent:<input type="text" name="time" value=" ">
Cost:<input type="text" name="cost" value=" ">
Totalcost:<input type="text" name="total" value=" ">
<br>
Timespent:<input type="text" name="time" value=" ">
Cost:<input type="text" name="cost" value=" ">
Totalcost:<input type="text" name="total" value=" ">
<br>
Timespent:<input type="text" name="time" value=" ">
Cost:<input type="text" name="cost" value=" ">
Totalcost:<input type="text" name="total" value=" ">
<br>
Timespent:<input type="text" name="time" value=" ">
Cost:<input type="text" name="cost" value=" ">
Totalcost:<input type="text" name="total" value=" ">
<input type="submit" value="Submit" onclick="updatesum()">
</form>
</body>
</html>