28,391
社区成员
发帖
与我相关
我的任务
分享
<script>
function checkInt(o){
theV=isNaN(parseInt(o.value))?0:parseInt(o.value);
if(theV!=o.value){o.value=theV;}
txtTotal.value=txtAmount.value*txtPrice.value;
}
function checkP(o){
theV=isNaN(parseFloat(o.value))?0:parseFloat(o.value);
theV=parseInt(theV*100)/100;
if(theV!=o.value){
theV=(theV*100).toString();
theV=theV.substring(0,theV.length-2)+"."+theV.substring(theV.length-2,theV.length)
o.value=theV;
}
txtTotal.value=txtAmount.value*txtPrice.value;
}
</script>
现有数量:
<input id=txtAmount value="1,226" onkeyup="checkInt(this);" onpaste="checkInt(this);" oncut="checkInt(this);" ondrop="checkInt(this);" onchange="checkInt(this);">
增加数量:
<input id=txtPrice value="" onkeyup="checkP(this);" onpaste="checkP(this);" oncut="checkP(this);" ondrop="checkP(this);" onchange="checkP(this);" style="border-right-width:0px;margin-right:0px;">
<input style="border-left-width:0px;margin-left:-4px;width:18px" value="件" readonly>
增加后数量:
<input id=txtTotal value="" style="border-right-width:0px;margin-right:0px;" readonly>
<input style="border-left-width:0px;margin-left:-4px;width:18px" value="件" readonly>
<br><br> 公式:现有数量+增加数量=增加后数量
<br><br>因为读取到的数据库数字千位会有一个逗号",",请高手帮忙解决。
<br><br>这个是乘法的,麻烦高手帮我改为加或者减法。<br><br>
</td>
<input id="txtAmount" name="txtAmount" type="text" value="<%=rs("txtAmount")%>" size="10" maxlength="10" onFocus="this.blur()" style="border:0;background:transparent;width:50px;height:15px;color:#FF0000" onKeyUp="value=value.replace(/[^\d\.]/g,'');SumNum();"/>
<input name="txtPrice" type="text" size="10" maxlength="200"/>
<input name="txtTotal" type="text" size="10" maxlength="200" onclick="txtTotal.value=eval(txtAmount.value)+eval(txtPrice.value)"/>