Link to home
Start Free TrialLog in
Avatar of mattybrown
mattybrown

asked on

image swap grid

My client is an artist. He wants to show a a grid of 9 images on a page. On clicking on an image, he wants it to change to another image which stays. So by the time the vistor clicks all nine images, they are looking a a completely different set of images than on entry.

Can anyone give any advice on the simplest way to do this.
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

for each image link you can have a onclick event which will call the following javascript function

<img src="" onclick="changepic(this)">

function changepic(thisObj)
{
thisObj.src=img_src;
}
Avatar of mattybrown
mattybrown

ASKER

So would that mean that by clicking each of the  nine initial images you could finish up with a completely different set of nine images on the same page?

Yes

Now, if the question is which image will be replacing the existing one: You might want to store those image URLs in an array.
Perfect. Thank you.

One other thing though. You said: 'those image URLs in an array'. Not too sure what you mean by this. The site will be a simple HTML site.

ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you. That's very helpful.