我需要编写一个程序来生成一个表并在单元格中显示一个随机生成的数字,该程序应该迭代10次,任何帮助?这就是我到目前为止所拥有的
<Script>
function generate() {
var counter = 0;
document.write('<table><tr>');
if(counter<10) {
document.write('<td>');
var tblcell = document.getElementById('tblcell2');
var cellnum = Math.floor(Math.random()*10);
tblcell.innerHTML = cellnum;
document.write('</td>');
counter++;
}
document.write('</tr></table>');
}
</Script>
<div class='format'>
<form>
<input type='button' onClick = 'generate()' value='Generate Colors'/>
</form>
</div>
<span id='tblcell2'></span>