<script>
function go(){
c.value=Math.round(a.value*b.value);
}
</script>
<style>
input{ime-mode:Disabled}
</style>
<input onKeypress="return (/[0-9,.]/.test(String.fromCharCode(event.keyCode)))" id=a onkeyup="go()">*<input onKeypress="return (/\d/.test(String.fromCharCode(event.keyCode)))" id=b onkeyup="go()"><input id=c readonly>
function go(){
c.value=Math.round(a.value*b.value);
}
</script>
<style>
input{ime-mode:Disabled}
</style>
<input onKeypress="return (/[0-9,.]/.test(String.fromCharCode(event.keyCode)))" id=a onkeyup="go()">*<input onKeypress="return (/\d/.test(String.fromCharCode(event.keyCode)))" id=b onkeyup="go()"><input id=c readonly>
但我测试过不可以实现
alert(qswhMul(23.4,12));
function qswhMul(n1,n2){
var m=0,s1=n1.toString(),s2=n2.toString();
try{m+=s1.split(".")[1].length}catch(e){}
try{m+=s2.split(".")[1].length}catch(e){}
return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
}
</script>
价格:<INPUT TYPE="text" NAME="jg" onpropertychange=c()><BR>
总计:<INPUT TYPE="text" NAME="zj" readOnly=true>
<script>
function c(){
with(document.all)zj.value=qswhMul(sl.value,jg.value);
}
function qswhMul(n1,n2){
var m=0,s1=n1.toString(),s2=n2.toString();
try{m+=s1.split(".")[1].length}catch(e){}
try{m+=s2.split(".")[1].length}catch(e){}
return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
}
</script>
多少版本才游泳,我这里不行
我用了好长的代码才实现的功能它一下就搞掂,
不用这个方法真是做死我了。利害利害!
onpropertychange方法我的ie5.0可用不过为什么会出现 " 23.4*12=280.79999999999995 "的结果呢?
还有没有什么函数可以更方便解决这个问题呢?贴多留两天...