I am new to JavaScript & am looking for some help doing simple multiplication of two numbers & displaying the result in another text box. I have been trying to get this working for days to no avail :(
Here is the basic HTML along with the JavaScript & a link to a fiddle here http://jsbin.com/egeKAXif/1/edit
What am I doing wrong?
The application I want to write will have at least 12 rows, how would I extend the JavaScript / HTML to accommodate this? Would each input identifier need to be unique?
Any help appreciated :)
<table width=80% border=0>
<tr>
<th>Box 1</th>
<th>Box 2</th>
<th>Result</th>
</tr>
<tr>
<td><input id=box1 type=text /></td>
<td><input id=box2 type=text onchange=calculate() /></td>
<td><input id=result /></td>
</tr>
</table>
<script>
function calculate() {
var myBox1 = document.getElementById('box1').value;
var myBox2 = document.getElementById('box2').value;
var result = document.getElementById('result');
var myResult = box1 * box2;
result.innerHTML = myResult;
}
</script>