hi,friends i want to show the trick of how to calculate the value of two text-field and got its sum in third text-field automatically and show sum when we type some value in second text-field.
JAVASCRIPT
<script> function sum() { var txtFirstNumberValue = document.getElementById('txt1').value; var txtSecondNumberValue = document.getElementById('txt2').value; var result = parseInt(txtFirstNumberValue) + parseInt(txtSecondNumberValue); if (!isNaN(result)) { document.getElementById('txt3').value = result; } } </script>
HTML
<input type="text" id="txt1" onkeyup="sum();" /> <input type="text" id="txt2" onkeyup="sum();" /> <input type="text" id="txt3" />