|
-
Jul 8th, 2001, 09:33 AM
#1
Thread Starter
Addicted Member
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 ?
-
Jul 8th, 2001, 10:00 AM
#2
Lively Member
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.
-
Jul 8th, 2001, 10:14 AM
#3
Thread Starter
Addicted Member
You're right about it, but I still gets error on this line. 
I'm REALLY new to javascript so if anyone could help !
-
Jul 8th, 2001, 10:43 AM
#4
Thread Starter
Addicted Member
Ok I found a solution !
Thanks for the help !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|