The Script below generates a sudoku (9 by 9) table and displays the table on screen.
what I am trying to do is to get a string of numbers entered into the text field labeled "enter values" on the page below the table, into each cell box of the sudoku table when the button labelled "load" is pressed. This would fill the sudoku table with characters, one character (from the text field) to each of cell boxes in the sudoku table.
It requires using a for loop, I tried using one in my function (g) but it doesn't work,... I really need your help on this one,...
_____________________________________________________
<html>
<head>
<title>Sudoku</title>
<style type="text/css">
body { background: gold; color: maroon}
.center { text-align: center }
td.changed { color: red }
</style>
<script type='text/javascript'>
//Script that generates sudoku table
function f(){
var s="<table border='5'>";
var k=0;
for (var b=0; b<3; b++) {
s+="<tr>";
for (var a=0; a<3; a++) {
s+="<td><table border='5'>";
for (var i=0; i<3; i++) {
s+="<tr>";
for (var j=0; j<3; j++) {
s+="<td><input type='text' id=' cell: "+b+""+a+""+i+""+j+"' size='1' class='bigcol'</td>";
k++;
}
s+= "</tr>";
}
s+= "</table></td>";
}
s+= "</tr>";
}
s+="</table>";
document.getElementById('sudoku').
innerHTML=s;
}
</script>
<script type='text/javascript'>
// attempt to initialize all the cell boxes in the sudoku table, that is to put values into table to make it playable
function g(){
var s = char.value;
var k = 0;
for (var s=0; s<5; s++) {
s.charAt(k)=document.getElementById('"+b+","+a+","+i+","+j+"').value;
k++;
}
}
</script>
</head>
<body onLoad="f();">
<form name='form1' class="center">
<div id="sudoku" align="center"></div>
<br/>
<p><b>Enter values</b> : <input type='text' size=81 id='char' />
<input type='button' value='Load' onclick='g()' /></p>
<input type="button" value="Submit" onClick="submit();"/>
<input type="button" value="Reload Page" onClick="window.location.reload()">
</form>
</body>
</html>