<p>请您输入金额:
<input type="text" name="spp" onKeyup="accu()">
</p>
<p>含手续费金额: <input name="dlp" value="0" disabled size="20">
</p>
<p><script language="JavaScript">
function accu()
{
with(document.form1){
spp.value=spp.value.replace(/[^\d\.]/g,'')
sp=spp.value
sp=parseFloat(sp)
var n=String(sp*1.015)
//if(/\./.test(n))return
n=n.split('.')
if(n.length==1)return dlp.value=n[0]
if(n[1].length<3)return dlp.value=n.join('.')
n[1]=n[1].replace(/(\d{3}).*/,"$1")
n=Math.round(parseInt(n.join(''),10)/10)/100
dlp.value=n
}
}
</script>
楼上是对的,但是为什么不直接赋值呢,还绕一圈0.0,arr=new Array(1,10,22,33,44,12)alert(arr.length)//
document.write("有个数:"+arr.length);