|
Error: 'document.getElemenetById(...)' is null or not an object
It works fine in a new document without any page elements, but when I add it to my existing page it gives an error:
'document.getElemenetById(...)' is null or not an object
Here's what I've modified/added to your original code:
-----------------START------------------
<script language="JavaScript" type="text/javascript">
<!--
onload="ShufImages();"
var ImgPath='../../images/100x133/';
var ImgAry=new Array('5001.jpg','5500_A.jpg','9404_A.jpg','20153.jpg','29001_B.jpg','29001_C.jpg');
var RandomNu;
var ImgCnt=1;
function ShufImages(){
RandomNu=Math.floor(Math.random()*(ImgAry.length-1));
if (ImgAry[RandomNu]!='X'){
document.getElementById('I'+ImgCnt).src=ImgPath+ImgAry[RandomNu];
ImgAry[RandomNu]='X';
ImgCnt++;
}
if (ImgCnt<ImgAry.length){ setTimeout('ShufImages()',10); }
}
//-->
</script>
******onload function in body*******
<body onload="ShufImages();" topmargin="0" leftmargin="20" link="#000000" vlink="#000000" alink="#000000" background="../../images/common/bkg_tile_3.gif">
******remaining script below********
<td height="133">
<img id="I1" src="../../images/100x133/" width="100" height="133"></td>
<td height="133">
<img id="I2" src="../../images/100x133/" width="100" height="133"></td>
<td height="133">
<img id="I3" src="../../images/100x133/" width="100" height="133"></td
----------------END------------------------
I want to be able to shuffle 6+ images.
Thanks!
|