
February 16th, 2005, 06:12 PM
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 22
Time spent in forums: 6 h 12 m 42 sec
Reputation Power: 0
|
|
|
Question about Image swapping within arrays
hello, I'm trying to create a project, and part of it includes using arrays with image swapping. Here's simplified code to show what I'm trying to do.
Code:
<script>
var imgArray = new Array(2);
imgArray[0] = new Image();
imgArray[0].src = "blue.gif";
function swapImage(){
document[imgArray[0]].src = "1.gif";
}
</script>
<img src="blue.gif" onClick="swapImage();">
and the error i get is:
Error: document[imgArray[0]] has no properties on line 9 (the error is from the firefox console.)
Also, the images don't display at all in internet explorer...hrm
Anyways, thanks for all the help you give,
Mike.
|