Wednesday,
10th Mar 2010
Paul

[javascript]

Multiple Image Rollover Script

This is a script for a 6 Button Rollover which looks and works like this:

Rollover Button 1 Rollover Button 2 Rollover Button 3 Rollover Button 4 Rollover Button 5 Rollover Button 6

First, cut and paste the following script in-between the <head> and </head> tags of your page:

Change the image files [i.e. "your-image-1-off.gif" & "your-image-1-on.gif"] in this script for your own images. You need 2 images for each button - 1 'on' image and 1 'off' image.

REMEMBER! BOTH THE ON AND THE OFF IMAGE MUST BE EXACTLY THE SAME SIZE!

Now use these individual lines of code to display each of your 6 buttons. Place these lines of code where you want your buttons to appear on your page:

Button 1

<a href="your page.cfm" onMouseOver="changer('img1',02)" onMouseOut="changer('img1',01)"><img name="img1" id="img1" border="0" width="150" height="50" src="your-image-1-off.gif" alt="Rollover Button 1"></a>

Button 2

<a href="your page.cfm" onMouseOver="changer('img2',04)" onMouseOut="changer('img2',03)"><img name="img2" id="img2" border="0" width="150" height="50" src="your-image-2-off.gif" alt="Rollover Button 2"></a>

Button 3

<a href="your page.cfm" onMouseOver="changer('img3',06)" onMouseOut="changer('img3',05)"><img name="img3" id="img3" border="0" width="150" height="50" src="your-image-3-off.gif" alt="Rollover Button 3"></a>

Button 4

<a href="your page.cfm" onMouseOver="changer('img4',08)" onMouseOut="changer('img4',07)"><img name="img4" id="img4" border="0" width="150" height="50" src="your-image-4-off.gif" alt="Rollover Button 4"></a>

Button 5

<a href="your page.cfm" onMouseOver="changer('img5',10)" onMouseOut="changer('img5',09)"><img name="img5" id="img5" border="0" width="150" height="50" src="your-image-5-off.gif" alt="Rollover Button 5"></a>

Button 6

<a href="your page.cfm" onMouseOver="changer('img6',12)" onMouseOut="changer('img6',11)"><img name="img6" id="img6" border="0" width="150" height="50" src="your-image-6-off.gif" alt="Rollover Button 6"></a>

At the beginning of each line, replace href="your page.cfm" with the correct URL's that you want your buttons to link to. Then change the image files in the <img> tag for your own image files [your 'off' image files] on each line and remember to change the width and height attributes to the sizes of your own images. You may also want to put your own button descriptions in the 'alt' attribute.

All your images and mouse functions have been numbered for you so you only need to change the file names.

If you have followed the instructions properly, you now have functioning Rollover Buttons on your page. You can add as many buttons as you wish as long as you remember to allocate new numbers to them.

Study the code here and try to find the pattern that will ensure you develop it correctly. For more instructions regarding adding more buttons, visit my  Simple Image Rollovers  page.