ie9浏览器javascript在form表单里不执行在firefox浏览器下正常 10
ie9浏览器javascript在form表单里不执行,但是去掉form标签又可以正常运行,在firefox浏览器下都能正常运行。代码如下:<script>functio...
ie9浏览器javascript在form表单里不执行,但是去掉form标签又可以正常运行,在firefox浏览器下都能正常运行。
代码如下:
<script>
function checkInt(o){
theV=isNaN(parseInt(o.value))?0:parseInt(o.value);
if(theV!=o.value){o.value=theV;}
amount.value=no.value*price.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;
}
amount.value=no.value*price.value;
}
</script>
<form name="form1" action="" method="post" >
数量:
<input id=no value=0 onkeyup="checkInt(this);" onpaste="checkInt(this);" oncut="checkInt(this);" ondrop="checkInt(this);" onchange="checkInt(this);">
单价:
<input id=price 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 id=amount value=0 style="border-right-width:0px;margin-right:0px;" readonly>
</form> 展开
代码如下:
<script>
function checkInt(o){
theV=isNaN(parseInt(o.value))?0:parseInt(o.value);
if(theV!=o.value){o.value=theV;}
amount.value=no.value*price.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;
}
amount.value=no.value*price.value;
}
</script>
<form name="form1" action="" method="post" >
数量:
<input id=no value=0 onkeyup="checkInt(this);" onpaste="checkInt(this);" oncut="checkInt(this);" ondrop="checkInt(this);" onchange="checkInt(this);">
单价:
<input id=price 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 id=amount value=0 style="border-right-width:0px;margin-right:0px;" readonly>
</form> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询