I want to generate click able table grid using javascript.
My code is not working.
- I created 2 text input fields for get values for row and column.
Button that will call
drawGrid()function onClick event.<input type="text" name="enter" class="enter" value="" id="inputX"/> <input type="text" name="enter" class="enter" value="" id="inputY"/> <input type="button" value="click" onclick="drawGrid();"/> <script language="JavaScript"> function drawGrid(){ document.write('<table border="1">'); var x_start = 1; var x_end = document.getElementById('inputX').value; var y_start = 1; var y_end = document.getElementById('inputY').value; // loop over all x values (rows) sequentally for( var x=x_start; x <= x_end; x++ ){ // open the current row document.write('<tr>'); // loop over all y values (cols) sequentally for( var y=y_start; y <= y_end; y++ ){ // write out the current x/y coordinate with a table cell document.write('<td> x:'+x+' y:'+y+'</td>'); } // end the current row document.write('</tr>'); document.write('</table>'); } } </script>