使用 JavaScript,我想在 soduku.setstring(); 中填充数字。一旦用户单击“Easy”按钮,进入表格。如何使用 onClick() 函数实现这一点?
function initialize() {
var col, row;
for (row = 0; row <=8; row++) {
for (col=0; col <= 8; col++) {
var cell = document.getElementById('cell_' + col + '_' + row);
if (!parseInt(cell.innerHTML)) {
// cell is empty
cell.onclick = selectCell;
cell.className = 'tofill';
}
}
}
document.onkeypress = keyPress;
}
function easygame(){
var sudoku.setString("240057360000008009378000200060041702080000005000005010130000000050003026000812000");
loadPuzzle(sudoku);
updateUI();
}
function updateUI(){
initialize();
}
<input type="button" value="Easy" onclick="easygame()"/>
<table align=center id="sudoku" cellspacing=0>
<tr>
<td id="cell_0_0"></td>
<td id="cell_1_0"></td>
<td id="cell_2_0"></td>
<td id="cell_3_0"></td>
<td id="cell_4_0"></td>
<td id="cell_5_0"></td>
<td id="cell_6_0"></td>
<td id="cell_7_0"></td>
<td id="cell_8_0"></td>
<tr>