I am trying to get the following script to replace the default images by a random image every time the page refreshes. I keep getting a boxID is null error. Why is boxID null?
<script type="text/javascript">
function randomThumbs(){
var unalafois=1;
for (unalafois=1; unalafois<9; unalafois++){
boxID=document.getElementById("'unalafois'")
var duh= Math.ceil(Math.random()*8);
boxID.src="thumbs/'+duh+'.jpg";
}}
</script>
Here is the HTML code:
<body onload="randomThumbs()">
<table>
<tr>
<td><img id="1" src="thumbs/1.jpg" /></td>
<td><img id="2" src="thumbs/2.jpg" /></td>
<td><img id="3" src="thumbs/3.jpg" /></td>
<td><img id="4" src="thumbs/4.jpg" /></td>
<td><img id="5" src="thumbs/5.jpg" /></td>
<td><img id="6" src="thumbs/6.jpg" /></td>
<td><img id="7" src="thumbs/7.jpg" /></td>
<td><img id="8" src="thumbs/8.jpg" /></td>
</tr>
</table>
</body>
Thanks!