window.onload = newCard; function newCard() { if (document.getElementById) { for (var i=0; i setSquare(i); } } else { alert("Sorry, your browser doesn't support this script"); } } function setSquare(thisSquare) { var currSquare = "square" + thisSquare; var colPlace = new Array(0,1,2,3,4,0,1,2,3,4,0,1,3,4,0,1,2,3,4,0,1,2,3,4); var colBasis = colPlace[thisSquare] * 15; var newNum = colBasis + getNewNum() + 1; document.getElementById(currSquare).innerHTML = newNum; } function getNewNum() { return Math.floor(Math.random() * 15); }