Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>try this: <a href="http://jsfiddle.net/JellyBelly/T65Lx/10/" rel="nofollow">http://jsfiddle.net/JellyBelly/T65Lx/10/</a></p> <p><strong>HTML</strong></p> <pre><code>&lt;select id="sel"&gt; &lt;option value=""&gt;Please Select the Logo&lt;/option&gt; &lt;option value="http://www.google.com/doodle4google/2010/images/doodle-sesame.gif"&gt;Logo 1&lt;/option&gt; &lt;option value="http://www.google.com/doodle4google/2010/images/doodle-holiday.gif"&gt;Logo 2&lt;/option&gt; &lt;option value="http://www.google.com/doodle4google/2010/images/doodle-popeye.gif"&gt;Logo 3&lt;/option&gt; &lt;/select&gt; &lt;div style="height:200px; width:250px;border:1px solid red;"&gt;&lt;img id="swapImg" src="http://www.google.com/doodle4google/2010/images/doodle-sesame.gif"&gt;&lt;/div&gt; </code></pre> <p><strong>JS</strong></p> <pre><code>$(document).ready(function() { $("#sel").change(function() { var imgUrl = $(this).val(); $("#swapImg").attr("src", imgUrl); }); }); </code></pre> <hr> <h2>You EDIT Question and I edit my Answer</h2> <p>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:</p> <p><strong>HTML:</strong></p> <pre><code>&lt;select id="sel"&gt; &lt;option value=""&gt;Please Select the Logo&lt;/option&gt; &lt;option value="http://www.google.com/doodle4google/2010/images/doodle-holiday.gif"&gt;Logo 1&lt;/option&gt; &lt;option value="http://www.google.com/doodle4google/2010/images/doodle-popeye.gif"&gt;Logo 2&lt;/option&gt; &lt;/select&gt; &lt;div id="swap" style="height:200px; width:250px;border:1px solid red;"&gt; &lt;input type="hidden" id="state" name="state" value="noImage"/&gt; &lt;/div&gt; </code></pre> <p><strong>JS</strong></p> <pre><code>$(document).ready(function() { $("#sel").live("change", function() { if ($("#state").val() == "noImage") { $("#swap").append( "&lt;img id='swapImg' src='" + $(this).val() + "'&gt;" ); $("#state").val('image') } else { $("#swapImg").attr("src", $(this).val()); } }); }); </code></pre> <p>demo: <a href="http://jsfiddle.net/JellyBelly/T65Lx/23/" rel="nofollow">http://jsfiddle.net/JellyBelly/T65Lx/23/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload