este es el formulario
Código:
y este java<input type="text" id="txt7" onKeyUp="sum();" size="8" value="0"/> <input type="text" id="txt27" onKeyUp="sum();"size="8" value="0"/> <input type="text" id="txt37" onKeyUp="sum();" size="8"value="0"/> <input type="text" id="txt47" onKeyUp="sum();" size="8"value="0"/> <input type="text" id="txt55" onKeyUp="sum();" size="8"value="0"/> <input type="text" id="txt65" onKeyUp="sum();" size="8"value="0"/> <input type="text" id="txt75" onKeyUp="sum();" size="8"value="0"/> <input type="text" id="txt8" value="0"/>
Código:
function sumtotal() { var txtFirstNumberValue = document.getElementById('txt7').value; var txtSecondNumberValue=document.getElementById('txt27').value; var txtThirdNumberValue = document.getElementById('txt37').value; var txtfourthNumberValue =document.getElementById('txt47').value; var txtfifthNumberValue=document.getElementById('txt55').value; var txtsixthNumberValue=document.getElementById('txt65').value; var txtseventhNumberValue=document.getElementById('txt75').value; if (txtFirstNumberValue == "") txtFirstNumberValue = 0; if (txtSecondNumberValue == "") txtSecondNumberValue = 0; if (txtThirdNumberValue == "") txtThirdNumberValue = 0; if (txtfourthNumberValue == "") txtfourthNumberValue = 0; if (txtfifthNumberValue == "") txtfifthNumberValue = 0; if (txtsixthNumberValue == "") txtsixthNumberValue = 0; if (txtseventhNumberValue == "") txtseventhNumberValue = 0; var result = Number(txtFirstNumberValue) + Number(txtSecondNumberValue) + Number(txtThirdNumberValue) + Number(txtfourthNumberValue) + Number(txtfifthNumberValue)+ Number(txtsixthNumberValue)+ Number(txtseventhNumberValue); if (!isNaN(result)) { document.getElementById('txt8').value = result; } }