资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
输入数量和价格自动计算输出金额的js代码
<img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%3E%20%0D%0Afunction%20checkInt(o)%7B%20%0D%0AtheV%3DisNaN(parseInt(o.value))%3F0%3AparseInt(o.value)%3B%20%0D%0Aif(theV!%3Do.value)%7Bo.value%3DtheV%3B%7D%20%0D%0AtxtTotal.value%3DtxtAmount.value*txtPrice.value%3B%20%0D%0A%7D%20%0D%0Afunction%20checkP(o)%7B%20%0D%0AtheV%3DisNaN(parseFloat(o.value))%3F0%3AparseFloat(o.value)%3B%20%0D%0AtheV%3DparseInt(theV*100)%2F100%3B%20%0D%0Aif(theV!%3Do.value)%7B%20%0D%0AtheV%3D(theV*100).toString()%3B%20%0D%0AtheV%3DtheV.substring(0%2CtheV.length-2)%2B%22.%22%2BtheV.substring(theV.length-2%2CtheV.length)%20%0D%0Ao.value%3DtheV%3B%20%0D%0A%7D%20%0D%0AtxtTotal.value%3DtxtAmount.value*txtPrice.value%3B%20%0D%0A%7D%20%0D%0A%3C%2Fscript%3E"> 数量: <input id=txtAmount value=0 onkeyup="checkInt(this);" onpaste="checkInt(this);" oncut="checkInt(this);" ondrop="checkInt(this);" onchange="checkInt(this);"> 单价: <input id=txtPrice value=0 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=0 style="border-right-width:0px;margin-right:0px;" readonly> <input style="border-left-width:0px;margin-left:-4px;width:18px" value="¥" readonly>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程