Note that there are some explanatory texts on larger screens.

plurals
  1. PODrop down menu showing improper images based on selection
    primarykey
    data
    text
    <p>I have a drop down box that will change an image if a new selection is made. Which i have got to work using the following code</p> <pre><code>&lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt;JS1&lt;/TITLE&gt; &lt;script LANGUAGE="JAVASCRIPT TYPE="TEXT/JAVASCRIPT"&gt; &lt;!-- image1 = new image(120,90) image1.src = "desk1.gif" image2 = new image(120,90) image2.src = "desk2.gif" image3 = new image(120,90) image3.src = "desk3.gif" image4 = new image(120,90) image4.src = "desk4.gif" function loadCatch(list) { var img = list.options[list.selectedIndex].value document.thumbnail.src = eval(img + ".src") } &lt;/SCRIPT&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;IMG SRC="desk1.gif" NAME="thumbnail" HEIGHT="90" WIDTH="120"&gt; &lt;FORM&gt; &lt;SELECT NAME="catch" onChange="loadCatch(this)"&gt; &lt;OPTION VALUE="Image1"&gt;Bands &lt;OPTION VALUE="Image2"&gt;Clips &lt;OPTION VALUE="Image3"&gt;Lamp &lt;OPTION VALUE="Image4"&gt;Else &lt;/SELECT&gt; &lt;/FORM&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre> <p>The trouble is my form has 3-4 parts so when you click back to edit the form stays selected with the correct option selected but but the image shows the default image, I know this is because it is using an onChange event so I have investigated another way using the following code:</p> <pre><code>&lt;script language="JavaScript" type="text/javascript"&gt; &lt;!-- var dropdownIndex = document.getElementById('colorsselect').selectedIndex; var dropdownValue = document.getElementById('colorsselect')[dropdownIndex].value; document.write(dropdownValue); //--&gt; &lt;/script&gt; </code></pre> <p>Which displays the correct image if I click to go back but it isn't live (onChange) so the user doenst get immediate result showing the new image.</p> <p>I'm not sure how to combine the two pieces of code above, hope someone can help?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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