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

  • SEARCH
  • Home
  • 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 6674555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:45:35+00:00 2026-05-26T03:45:35+00:00

Actually I have a select dropdown. On the select of every option, I need

  • 0

Actually I have a select dropdown. On the select of every option, I need to load an image(Say in a Div). How do I accomplish this is jquery.

I tried something here:

http://jsfiddle.net/refhat/T65Lx/2/

My other two images are here:

http://www.google.com/doodle4google/2010/images/doodle-holiday.gif
http://www.google.com/doodle4google/2010/images/doodle-popeye.gif

UPDATE 1:

My question is something like this.

jQuery add image inside of div tag

UPDATE 2

@JellyBelly: No offence, In deed this is a good answer so far, But It has quite a few bugs, First after selecting some image in the dropdown and then if you go back to first select with value=””, It shows some non existing image(Actually this doesn’t exist.) (Screen Shot AtachedBUG 1)
2: If you were in the page and had selected say 2nd Image and then if you refresh, It doesn’t reset the image, rather shows that Image for first option of select.the scripts crashes, It doesn’t load anything. I think this is because we are just doing this on DOM ready.

THANKS

  • 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-05-26T03:45:36+00:00Added an answer on May 26, 2026 at 3:45 am

    try this: http://jsfiddle.net/JellyBelly/T65Lx/10/

    HTML

    <select id="sel">
        <option value="">Please Select the Logo</option>
        <option value="http://www.google.com/doodle4google/2010/images/doodle-sesame.gif">Logo 1</option>
        <option value="http://www.google.com/doodle4google/2010/images/doodle-holiday.gif">Logo 2</option>
        <option value="http://www.google.com/doodle4google/2010/images/doodle-popeye.gif">Logo 3</option>
    </select>
    <div style="height:200px; width:250px;border:1px solid red;"><img id="swapImg" src="http://www.google.com/doodle4google/2010/images/doodle-sesame.gif"></div>
    

    JS

    $(document).ready(function() {
        $("#sel").change(function() {
            var imgUrl = $(this).val();
            $("#swapImg").attr("src", imgUrl);
        });
    });
    

    You EDIT Question and I edit my Answer

    If I understand correctly, you have the initial state and an empty div in the first selection you want to hang a picture and subsequent selections you want to replace the image right?
    If so ‘it was, here’s how you do:

    HTML:

    <select id="sel">
        <option value="">Please Select the Logo</option>
        <option value="http://www.google.com/doodle4google/2010/images/doodle-holiday.gif">Logo 1</option>
        <option value="http://www.google.com/doodle4google/2010/images/doodle-popeye.gif">Logo 2</option>
    </select>
    <div id="swap" style="height:200px; width:250px;border:1px solid red;">
        <input type="hidden" id="state" name="state" value="noImage"/>
    </div>
    

    JS

    $(document).ready(function() {
    
        $("#sel").live("change", function() {
            if ($("#state").val() == "noImage") {    
                $("#swap").append(
                    "<img id='swapImg' src='" + $(this).val() + "'>"
                );
                $("#state").val('image')
            } else {
               $("#swapImg").attr("src", $(this).val());
            }
        });
    
    });
    

    demo: http://jsfiddle.net/JellyBelly/T65Lx/23/

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

Sidebar

Related Questions

I have tried many ways to select an option with jquery including .val(0) .attr('selected',
say I have this $result = mysql_query('SELECT views FROM post ORDER BY views ASC');
This is a minimal test case of some code that I actually have. It
Actually I have a file . I am working in linux environment. I need
Actually I have to upload pdf files and need to read on my website
How to use related select boxes in Symfony ? Let's say, I have a
I have this page: http://www.ryancoughlin.com/files/xml/ - if you select User -> Someones name You
I have two problems relating to using Jquery mobile UI framework dropdown selectors when
Ok, say I have a query: SELECT * FROM TABLE_AWESOME WHERE YEAR = :AMAZINGYEAR;
I have problem on passing jquery variable on codeigniter controller. actually i want to

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.