下面的代码提示total未定义。
请问如何修改
谢谢。<form>
<input id=mon name=mon value="1" >
<input id=total name=total value="10"><script language="JavaScript">
------
------
if(navigator.userAgent.indexOf("MSIE")>0){
document.getElementById('mon').attachEvent("onpropertychange",txChange);
}else if(navigator.userAgent.indexOf("Firefox")>0){
document.getElementById('mon').addEventListener( "input",txChange2,false);
}
function txChange(){
total.value=Math.round(mon.value*10*1000)/1000;
}
function txChange2(){
total.value=Math.round(mon.value*10*1000)/1000;
}
</script></form>

解决方案 »

  1.   

    [code=JScript][<form>
    <input id=mon name=mon value="1" >
    <input id=total name=total value="10"><script language="JavaScript">
    ------
    ------
    if(navigator.userAgent.indexOf("MSIE")>0){
    document.getElementById('mon').attachEvent("onpropertychange",txChange);
    }else if(navigator.userAgent.indexOf("Firefox")>0){
    document.getElementById('mon').addEventListener( "input",txChange2,false);
    }
    var total = document.getElementById('total ');
    function txChange(){
    total.value=Math.round(mon.value*10*1000)/1000;
    }
    function txChange2(){
    total.value=Math.round(mon.value*10*1000)/1000;
    }
    </script></form>/code]
      

  2.   

    var total = document.getElementById('total ');
    你的页面中要有一个id为:total的定义。