simonpearce
ISP
Hello!
I'm using the code from:
which seemed quite good. I have about 11 images I want to be able to swap and I'm using this code:
<script type="text/javascript">
var revert = new Array();
var inames = new Array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11');
// Preload
if (document.images) {
var flipped = new Array();
for(i=0; i<inames.length; i++) {
flipped = new Image();
flipped.src = "images/"+inames+"b.gif";
}
}
function over(num) {
if(document.images) {
revert[num] = document.images[inames[num]].src;
document.images[inames[num]].src = flipped[num].src;
}
}
function out(num) {
if(document.images) document.images[inames[num]].src = revert[num];
}
</script>
and this in the img src:
<img border="0" src="images/1.gif" name="1" onMouseOver="over(0)" onMouseOut="out(0)" width="379" height="24">
Only when I run the page it swaps the wrong images? It seems to be getting confused with images that I don't want swapping (like the logo at the top of the page!!)
Any ideas what might be wrong with the script?
Thanks in advance.
Simon
I'm using the code from:
which seemed quite good. I have about 11 images I want to be able to swap and I'm using this code:
<script type="text/javascript">
var revert = new Array();
var inames = new Array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11');
// Preload
if (document.images) {
var flipped = new Array();
for(i=0; i<inames.length; i++) {
flipped = new Image();
flipped.src = "images/"+inames+"b.gif";
}
}
function over(num) {
if(document.images) {
revert[num] = document.images[inames[num]].src;
document.images[inames[num]].src = flipped[num].src;
}
}
function out(num) {
if(document.images) document.images[inames[num]].src = revert[num];
}
</script>
and this in the img src:
<img border="0" src="images/1.gif" name="1" onMouseOver="over(0)" onMouseOut="out(0)" width="379" height="24">
Only when I run the page it swaps the wrong images? It seems to be getting confused with images that I don't want swapping (like the logo at the top of the page!!)
Any ideas what might be wrong with the script?
Thanks in advance.
Simon