• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 591
  • Last Modified:

replace html option value by an image

Dear experts,

I am creating an html survey and I would like to replace an option value by an image. I mean, if the user choose Yes, instead of outputting the string Yes, the survey should show a green dot. On the other hand if the user chose no, it should show a red dot.

Could you please help me with that?

Attached goes a screenshot with the source code for reference.

thanks in advance,

  • 2
  • 2
1 Solution
Green/red dot where?
glepizaAuthor Commented:
It should go in the output form. If the user choose yes, the output should show a greed dot. like the attached image.
I don't know how one relates to the other - is this on the same page?
You need to post some code so we can see it in context.
Please  add three images with name as image1.jpg,image2.jpg,image3.jpg
Or As per your image name change within the select option.
Or you could even write switch case or if condition in js function to provide the image name if you want to keep option value as 'YES' and 'NO'

Please do let me know if any issue

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Love to marry an free matimonial website</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
 <script type="text/javascript">




<div class="main">
<img src="" name="image-swap">
<select name="kitchen_color" id="kitchen_color">
<option value="imag1.jpg">None</option>
    <option value="imag2.jpg">Yes</option>
    <option value="imag3.jpg">NO</option></div>
glepizaAuthor Commented:
Yup, just what I needed. Im going to use the if statement. Thanks again, I just needed an starting up point.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now