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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:09:55+00:00 2026-05-26T10:09:55+00:00

I am doing an advertising form , with preview ad below. So as user

  • 0

I am doing an advertising form , with preview ad below.

So as user types their advert, the preview updates as they go.
One of the selections is dropdown box, where they can choose their service type..

I have a master div, for the preview. And I want to add a image in one corner of that div, based on the selection choice from the advert form…

So in drop down select, we have:

<select style="width: 220px; display: none;" id="speedB" name="category">
    <option value=""<?if ($category == ""){?> selected="selected"<?}?>>Please Select</option>
    <option value="1"<?if ($category == "1"){?> selected="selected"<?}?>>Pest Inspectors</option>
    <option value="3"<?if ($category == "3"){?> selected="selected"<?}?>>Building Inspectors</option>
    <option value="2"<?if ($category == "2"){?> selected="selected"<?}?>>Removalists</option>
    <option value="5"<?if ($category == "5"){?> selected="selected"<?}?>>Conveyancing</option>
    <option value="4"<?if ($category == "4"){?> selected="selected"<?}?>>Pool Inspectors</option>
</select>

And in the preview div I have:

<div class="dirResult">
<div class="showImage"></div>
</div>

So the div “showImage” is what I want to initiate based on the choice user has selected in the select dropdown in the form.

so:
if value=”1″ then show pest.png
if value=”2″ then show build.png
so on and so forth.

Is there a simple way to do this ?
I suppose showImage div must be pre-set to display:none

But after that I am stumped.

UPDATE

Based on ingenu’s answer below.

I am thinking perhaps add different div classes instead of individual pngs, that way I can control css etc.

So something like :

$('#speedB').change(function() {
                      var myimages = {
                        '': '.nothing',
                        '1': '.pest',
                        '2': '.build'
                      }
                      var selectedImage = myimages[$(this).val()];
                      $('#topright').html('not sure what to put here');});

Then in css have:

.pest {
background: url("pest.png") no-repeat scroll 0 0 transparent;
height: 70px;
position: absolute;
right: 0;
top: 0;
width: 70px;

}

  • 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-26T10:09:56+00:00Added an answer on May 26, 2026 at 10:09 am

    Here’s a prototype: (untested)

    $('#speedB').change(function() {
      var myimages = {
        '': 'default.png',
        '1': 'pest.png',
        '2': 'build.png'
      }
      var selectedImage = myimages[$(this).val()];
      $('.showImage').html('<img src="'+selectedImage+'" alt="" />');
    });
    

    Edit: Inserting containers instead of images:

    $('#speedB').change(function() {
      var myclasses = {
        '': 'default',
        '1': 'pest',
        '2': 'build'
      }
      var selectedClass = myclasses[$(this).val()];
      $('.showImage').html('<div class="'+selectedClass+'"></div>');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Doing the below will reproduce my problem: New WPF Project Add ListView Name the
Doing a some practice questions for exam tomorrow can't figure out this one What
Doing this in a console program: object x = new string(new char[0]); If one
In my onbeforeunload event, it asked the user whether they want to leave the
Doing a couple rotations in Matlab, one which is rotation about the y-axis, however
Doing an alert() on one of my variables gives me this result [object NodeList]
I'm doing an advertising feature on a website: The more you pay, the likelier
doing a simple login for my website, which will hopefully keep the user logged
I'm looking for guidance. Here is what I'm doing. I'm creating an advertising/publishing script
Doing odd/even styling with jQuery is pretty easy: $(function() { $(.oddeven tbody tr:odd).addClass(odd); $(.oddeven

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.