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 7800301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:35:29+00:00 2026-06-02T00:35:29+00:00

I having problems with a script to change an image on a page based

  • 0

I having problems with a script to change an image on a page based on a option selected from a drop down menu. I can make it work when I have one drop down changing one image. But I’m trying to expand my code so that I can replace two images from a single drop down menu and I’m not really sure what is wrong with my code.

<script>
window.onload=function()
{

    bp='http://www.nessasneedles.co.uk/images/layout/shop/samples/fabric/', //base url     of your images
    imgnum=4, //Number of your images. This should match on your comboboxes options.
    thumb1=document.getElementById('outer_example'), //id of your outer image that will     be changing. The outer of the bag
    thumb2=document.getElementById('lining_example'), //id of the image using in the if     clause for second image
    combobox1=document.getElementById('outer_option'), // id of your combobox. The     select box for the outer design.

    combobox1.onchange=function()
    {
    thumb1.src=bp+'img'+this.value+'.jpg';
    
    if (this.value = "Cats") {
        thumb2.src=bp+'img'+"Purple Gingham"+'.jpg';
    } else {
        thumb2.src=bp+'img'+"Pink"+'.jpg';
        };    
    };
        

}
</script>
  • 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-02T00:35:31+00:00Added an answer on June 2, 2026 at 12:35 am

    You need a double == in your if statement:

    if (this.value == "Cats") {
    

    Single = for assigning a value, double == for comparison.

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

Sidebar

Related Questions

I am having problems changing the 'from' email header in the following script. Everthing
Having problems with a small awk script, Im trying to choose the newest of
I recently created my first bash script, and I am having problems perfecting it's
I've been having real problems trying to get a ruby script to run through
I'm having perl regex matching problems with a network script I have, I've managed
Having a problem executing a Python script from a .NET web service. The web
Here's a fun little script I'm trying to make. Flash words from an array
I'm having some issues with a content script being injected to the same page
I'm having a problem with my python script. It's printing massive amounts of data
I'm having a problem with Python's subprocess.Popen method. Here's a test script which demonstrates

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.