求个大神教一教如何两个文本框的值相加显示在另一个文本框

wenshigang 2018-04-27 12:44:13
<form method="post" name="myform" action="Admin_ClothesAdd.asp?mark=Clothes">
<td height="230"><div align="center">
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr bgcolor="#ECF5FF">
<td width="27%" height="60" align="center">
<div align="center" style="height:15px;">服装名称</div>
<div align="center" style="height:15px;">库存数量</div>
<div align="center" style="height:15px;">租借数量</div>
<div align="center" style="height:15px;">服装总数</div></td>
<td width="73%">
<input name="explain" type="text" value="" size="40">
<input name="kucun" type="text" value="" size="40">
<input name="zujie" type="text" value="" size="40">
<input name="zongshu" type="text" value="" size="40">

如图,我现在想让总数=库存+租借,看了很多都不能用,求一个大神指点迷津
...全文
1022 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wcwtitxu 2018-04-27
  • 打赏
  • 举报
回复
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
	function updateTotal() {
		var form = document.myform;
		var a = ['explain', 'kucun', 'zujie'], sum = 0;
		for (var i=0; i<a.length; i++) {
			sum += parseInt($.trim(form[a[i]].value), 10) || 0;
		}
		form.zongshu.value = sum;
	}
	$(document).on('change', updateTotal);
	$(document).on('input', updateTotal);
</script>

   <form method="post" name="myform" action="Admin_ClothesAdd.asp?mark=Clothes">
            <td height="230"><div align="center"> 
                <table width="100%" border="0" cellspacing="1" cellpadding="0">
                  <tr bgcolor="#ECF5FF"> 
                    <td width="27%" height="60" align="center"> 
                    <div align="center" style="height:15px;">服装名称</div>
                    <div align="center" style="height:15px;">库存数量</div>
                    <div align="center" style="height:15px;">租借数量</div>
                    <div align="center" style="height:15px;">服装总数</div></td>
                    <td width="73%">
                    <input name="explain" type="text" value="" size="40">
                    <input name="kucun" type="text" value="" size="40">                                        
                     <input name="zujie" type="text" value="" size="40">
                    <input name="zongshu" type="text"  value="" size="40">
wenshigang 2018-04-27
  • 打赏
  • 举报
回复
好的,我回去试试,谢谢大神
usecf 2018-04-27
  • 打赏
  • 举报
回复
一样吧 你把javascript的改成你vb的试试
usecf 2018-04-27
  • 打赏
  • 举报
回复
<html> <head> <script type="text/javascript"> function sum() { var one = document.getElementById("input1"); var two = document.getElementById("input2"); var three = document.getElementById("input3"); three.value= parseInt(one.value)+parseInt(two.value); } </script> </head> <body> <input type="text" id="input1"/> <span>+</span> <input type="text" id="input2"/> <span>=</span> <input type="text" id="input3"/> <input type="button" onclick="sum()" value="sum"/> </body> </html>
wenshigang 2018-04-27
  • 打赏
  • 举报
回复
但是我前面定义了编码是vb

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧