<table>
<tr>
<td>编号</td>
<td><input type="text" name="price1"></td>
</tr>
<tr>
<td>编号</td>
<td><input type="text" name="price2"></td>
</tr>
<tr>
<td>编号</td>
<td><input type="text" name="price3"></td>
</tr>
<tr>
<td>编号</td>
<td><input type="text" name="price4"></td>
</tr>
<tr>
<td>总金额</td>
<td>
一共是<input type="text" name="count">元
</td>
</tr>
</table>jsp文本框中的金额分别是:price1,price2,price3,price4。请教在txt文本框填数值,然后动态把金额的值累加,显示到当前页面的count文本框中.(txt文本框内填值,不分先后)请教各位,万分感谢。
<tr>
<td>编号</td>
<td><input type="text" name="price1"></td>
</tr>
<tr>
<td>编号</td>
<td><input type="text" name="price2"></td>
</tr>
<tr>
<td>编号</td>
<td><input type="text" name="price3"></td>
</tr>
<tr>
<td>编号</td>
<td><input type="text" name="price4"></td>
</tr>
<tr>
<td>总金额</td>
<td>
一共是<input type="text" name="count">元
</td>
</tr>
</table>jsp文本框中的金额分别是:price1,price2,price3,price4。请教在txt文本框填数值,然后动态把金额的值累加,显示到当前页面的count文本框中.(txt文本框内填值,不分先后)请教各位,万分感谢。
解决方案 »
- 为什么我在linux下没法使用cookie?????
- 关于数据库连接池dbcp的疑惑
- 触发器的问题 sql server 2000
- 急求EJB 实体Bean中往带自动增长列表中添加数据问题
- 如何用java实现web服务器的监控?
- 请教windows xp下面apache server和tomcat的整合~~~
- 您在用J2EE开发企业管理系统吗?(顺带个好消息:Chinahelp.net上可申请免费50M邮箱)
- 为什么getInputForward是null值?
- petstore deploy
- 列表页没有数据,急!!!
- poi excel 导出时 页眉/页脚出现了乱码
- struts2 ActionSupport 及 项目起名问题,高手请进!
<script language="javascript" type="text/javascript">
function sum(){
var result = 0;
var i=0;
for (i=1; i<=4; i++){
var price = document.getElementsByName('price'+i)[0].value;
if(!(isNaN(price)||price=="")) result += parseFloat(price);
}
document.getElementsByName('count')[0].value = result;
}
</script>
<table>
<tr>
<td>编号</td>
<td><input type="text" name="price1" onblur="sum();"></td>
</tr>
<tr>
<td>编号</td>
<td><input type="text" name="price2" onblur="sum();"></td>
</tr>
<tr>
<td>编号</td>
<td><input type="text" name="price3" onblur="sum();"></td>
</tr>
<tr>
<td>编号</td>
<td><input type="text" name="price4" onblur="sum();"></td>
</tr>
<tr>
<td>总金额</td>
<td>
一共是<input type="text" name="count">元
</td>
</tr>
</table>