-
Javascript help.
Fairly new that I am to javascript, I need help with this simple script :
Code:
<Script Language="JavaScript">
<!--
var images = new array[3];
images[0] = 'p1txtrl1.jpg'; // Services
images[1] = 'p1txtrl2.jpg'; // Sites
images[2] = 'p1txtrl3.jpg'; // Références
images[3] = 'p1txtrl.jpg'; // Image par défaut
var rollovers_on = new array[2];
rollovers_on[0] = 'p1btsrrl.jpg'; // Services
rollovers_on[1] = 'p1btstrl.jpg'; // Sites
rollovers_on[2] = 'p1btrfrl.jpg'; // Références
var rollovers_off = new array[2];
rollovers_off[0] = 'p1btsrup.jpg'; // Services
rollovers_off[1] = 'p1btstup.jpg'; // Sites
rollovers_off[2] = 'p1btrfup.jpg'; // Références
function RollOver(Img, Index)
{
document.frmMenu.imgCentral.src = images[Index];
Img.src = rollovers_on[Index];
}
function RollOut(Img, Index)
{
document.frmMenu.imgCentral.src = images[3];
Img.src = rollovers_off[Index];
}
// Procédure principale
window.defaultStatus = 'Accueil';
document.frmMenu.imgCentral.src = images[3];
// -->
</Script>
What's wrong with this code ?
-
var images = new array[3];
only makes room for three (3) values in that array. I suggest you write
var images = new array[4];
instead (and the same on rollovers_on and rollovers_off).
At least, this is how arrays works in C++, I assume they work the same in JavaScript.
-
You're right about it, but I still gets error on this line. :(
I'm REALLY new to javascript so if anyone could help !
-
Ok I found a solution !
Thanks for the help !