<head> <script> function addIt() { var value1 = parseInt ("inputA"); if (isNaN ( inputA )) value1 = 5; //это для проверки var value2 = document.getElementById("inputB").value; var sum = value1 * value2; var textout = + sum + ' р.'; document.getElementById('output').innerHTML = textout; } </script> </head> <body> <table> <tr> <td id="inputA">31920</td> <td><input type="text" size="2" id="inputB" onkeyup="addIt()"></td> <td id="output"></td> </tr> </table> </body>
<table> <tr> <td id="inputA">31920</td> <td><input type="text" size="2" id="inputB" onkeyup="addIt()"></td> <td id="output"></td> </tr> </table> <script> function addIt() { var value1 = parseInt(document.getElementById("inputA").innerHTML) ; if(isNaN(value1)) value1 = 5 ; //это для проверки var value2 = parseInt(document.getElementById("inputB").value) ; var sum = value1 * value2 ; var textout = + sum + ' р.' ; document.getElementById('output').innerHTML = textout ; } ; </script>