Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7922765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:04:42+00:00 2026-06-03T17:04:42+00:00

This might be a really newb question, but I really need help here, I

  • 0

This might be a really newb question, but I really need help here, I have 5 thumbnails and a big image.

What I simply want to do is, when you click on a thumbnail, the big image change. The big image is always an animated gif, thats why I used some preloaded images. (I had a problem on FF where the animation wasnt showing on changing only the src)

Here’s the code

function preloader()
{
if (document.images)
    {
      pic1= new Image(800,550);
      pic1.src='contest-landing/card_large1.gif';

      pic2= new Image(800,550);
      pic2.src='contest-landing/card_large2.gif';

      pic3= new Image(800,550);
      pic3.src='contest-landing/card_large3.gif';
    }
}

$j("li img").on("click", function(){
     var whatImage = $j(this).attr('id');
     //document.bigImage.src = pic3.src That is working, its always showing the image #3
     document.bigImage.src = pic+whatImage.src // I cant get that to work, so it doesnt show always the same image
 });

HTML:

<ul>
    <li><img src='/card_thumb1.jpg' id="1" class="cardThumb"></li>
    <li><img src='/card_thumb2.jpg' id="2" class="cardThumb"></li>
    <li><img src='/card_thumb3.jpg' id="3" class="cardThumb"></li>            
</ul>

<img id="bigImage" name="bigImage" src='card_large1.gif' width="800" height="550"  />

So, my question is more syntax related. I want to replace that line

document.bigImage.src = pic3.src

so the number is taken from the id.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:04:43+00:00Added an answer on June 3, 2026 at 5:04 pm

    Try storing the Image objects in properties of another object instead of using separate variables for each one.

    var pics = {}; // An object to hold our Images. Always use `var` to declare variables!
    
    function preloader() {
    
        if (document.images) {
    
            pics[1] = new Image(800, 550);
            pics[1].src='contest-landing/card_large1.gif';
    
            pics[2] = new Image(800, 550);
            pics[2].src='contest-landing/card_large2.gif';
    
            pics[3] = new Image(800, 550);
            pics[3].src='contest-landing/card_large3.gif';
    
        }
    }
    
    $j("li img").on("click", function(){
        var whatImage = this.id;
        document.getElementById('bigImage').src = pics[whatImage].src;
    });
    

    You could (and should) use a non-numeric id attribute for those elements, by the way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a really ignorant question, but I have a need to create
This might sound very very basic 101 type question, but I really need help
This question might seem really silly to most of the enlightened folks here. But
this might be really simple, but just need some help in getting the syntax
hey guys, this might be really stupid, but hopefully someone can help. I'm trying
This might seem like a really dumb question, but I am writing an application
This might be a noob question. but I'm really torned between adding documents to
I know this might be really a simple question but I don't know the
This might be a really dumb question, but is it dumb to load the
This might be a very stupid question :P But I found this really interessting:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.