js 实时监听input中值的变化,值改变时自动计算填充到另一个input中


<table style="border-collapse:separate; border-spacing:0px 10px;">
 <tr>
  <td align="right">应收现金:</td>
  <td><input id="accountReceivable" autoComplete='off'></td>
  <td>元,折扣:</td>
  <td><input id="vipdiscount"  ></td>
  <td align="right">实收:</td>
  <td><input id="receipts" readonly="true"></td>
  <td>元 </td>
  <td>消费类型:<select id="conType"><option value="1" >报名费</option><option value="2" >酒水零食费</option></select></td>
  <td><a id="btnSend" class="easyui-linkbutton">提交</a></td>
									   
 </tr>
</table>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
	<script type="text/javascript">
$(function(){  
 
	$('#accountReceivable').bind('input propertychange', function() {  
		var a = $('#accountReceivable').val();
		var b = $('#vipdiscount').val();
		var sum= a * b;
		
	    $('#receipts').val(sum);  
	}); 
  
}) 
</script>

实时监听input值的变化,进行计算

<input type="text" id="borrowValue">
	<span id="repayValue">0</span>
 <input type="text" id="repayValue"  >
 
	<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
	<script type="text/javascript">
		$('#borrowValue').bind('input propertychange', function() {
			var loadInterest = '4';
	  		var borrowValue = $(this).val();
	  		var repayValue = loadInterest*30*borrowValue/10000;
			$("#repayValue").html(repayValue);
		});
	</script>

-

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值