PettyRider
10-31-2004, 03:03 AM
Okay, I'm trying to do this random image thing with two images. Here is the jist of everything:
<head>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
var img_header = new Array("header_1.jpg", "header_2.jpg",
"header_3.jpg", "header_4.jpg");
var img_main= new Array("main_1.jpg", "main_2.jpg",
"main_3.jpg", "main_4.jpg");
var l = img_header.length;
var rnd_no = Math.round((l-1)*Math.random());
document.header.src = "img_header[rnd_no]";
document.main.src = "img_main[rnd_no]";
//-->
</SCRIPT>
</head>
<body>
<img src="header.jpg" name="header">
<img src="main.jpg" name="main">
</body>
I just get the error "'document.header' is null or not an object" and "'document.main' is null or not an object," but they are objects. They're images are they not?
I need to do this so the random images correspond with each other. Any other ways to do it? This is driving me crazy.
<head>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
var img_header = new Array("header_1.jpg", "header_2.jpg",
"header_3.jpg", "header_4.jpg");
var img_main= new Array("main_1.jpg", "main_2.jpg",
"main_3.jpg", "main_4.jpg");
var l = img_header.length;
var rnd_no = Math.round((l-1)*Math.random());
document.header.src = "img_header[rnd_no]";
document.main.src = "img_main[rnd_no]";
//-->
</SCRIPT>
</head>
<body>
<img src="header.jpg" name="header">
<img src="main.jpg" name="main">
</body>
I just get the error "'document.header' is null or not an object" and "'document.main' is null or not an object," but they are objects. They're images are they not?
I need to do this so the random images correspond with each other. Any other ways to do it? This is driving me crazy.