金额1<input type=text name=text1 value=0 onpropertychange=woyingjie()>
金额2<input type=text name=text2 value=0 onpropertychange=woyingjie()>
金额3<input type=text name=text3 value=0 onpropertychange=woyingjie()>
总计<input type=text name=text4 value=0>
<script>
function woyingjie(){
var text1=parseInt(document.all.text1.value);
var text2=parseInt(document.all.text2.value);
var text3=parseInt(document.all.text3.value);
var text4=text1+text2+text3;
document.all.text4.value=text4;
}
</script>

解决方案 »

  1.   

    <form name=form1>
    金额1<input type=text name=price value=0 onpropertychange=calc()>
    金额2<input type=text name=price value=0 onpropertychange=calc()>
    金额3<input type=text name=price value=0 onpropertychange=calc()>
    总计<input type=text name=sumprice value=0>
    </form><script>
    function calc()
    {   var sum=0;
        for(var i=0;i<form1.price.length;i++)
        {
            if (!isNaN(Number(form1.price[i].value)) sum+=Number(form1.price[i].value);
        }
        form1.sumprice.value=sum;
    }
    </script>