Jump to content

Change one image by clicking another


nd3_2000

Recommended Posts

hi guys, I have looked over Google for this and cant seem to find what I need atall!

 

Basically I have a webpage with small thumbs at the bottom and a main image at the top, I would like to change the main image on the page when I click on any of the thumbnails.........

 

Does anybody have a function they can provide me with or giudance for this as I thought this wqould be easy to find but its not apparantly

 

Cheers

Neil

Link to comment
Share on other sites

if you want to fire the event  on your thumbs set this attribute, to each one :

 

<image src=".." onclick="changeMainImage('put here the path of you main image');" >

then you can put this function on a script tag:

<script type="text/javascript">
    function changeMainImage(url)
    {
          /*now here you have to get the element of you main top image, supposing that you are usins as an id "myMainImage" ok!
           */
          var mainImage = document.getElementById('myMainImage');
          // here we are setting to the maing image the path you receive as a param
           mainImage.src = url;
    }
</script>

 

and i think that's all :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.