First, I am not too verse with JavaScript. I would like to build a HTML table TD elements with content dynamically using JavaScript. Here is my code that is not working properly.
<script type="text/javascript">
function changed(num){
a1=num;
a2=num+1;
a3=num+2;
for(var i=1;i<=3;i++){
document.getElementById("boxA"+i).innerHTML=eval('a'+i);
}
}
</script>
Here is the HTML code:
<input type="text" name="box" onChange="changed(this.value);">
<table width="400" border="10" cellpadding="5">
<tr>
<td id="boxA1"> </td>
<td id="boxA2"> </td>
<td id="boxA3"> </td>
</tr>
</table>
If I entered the value 1 in the input field, the following values should be 1, 2, 3