View Full Version : Can a mouseover be used to change a different image?

09-22-2011, 11:30 PM
I am quite new to JavaScript code and have a challenge. I would like to add a mouseover script to several different images e.g. Manufacturer logos which would cause a background image to change accordingly. There are eight different logos which would refer to eight background images respectively. I have found several scripts which cause the image which has the mouseover to change but not any which cause a different image to change. Is this practical using JavaScript? Any help is greatly appreciated!

Old Pedant
09-23-2011, 01:06 AM
Show us the HTML with the background image in place. Yes, this is easy, but that actual code depends on what HTML you are using.

09-23-2011, 07:52 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<style type="text/css">



<script type="text/javascript">

function BG(src){

<img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" onmouseover="BG('http://www.vicsjavascripts.org.uk/StdImages/Two.gif');"/>
<img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg" onmouseover="BG('http://www.vicsjavascripts.org.uk/StdImages/Three.gif');"/>


09-23-2011, 08:50 AM
not sure what you mean but it seen like your code is working fine.


<img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" onmouseover="BG(this);" name="Two"/>
<img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg" onmouseover="BG(this);" name="Three"/>


function BG(x){

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum