Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript Display Selected Image
    primarykey
    data
    text
    <p>I have another Javascript problem that I could really use help with. Again I am sorry for such silly questions but I am really new at this and I just have no idea what I am doing. I have the code so far of what I need and then notes in the script for the information I am missing.</p> <p>Thank you!</p> <pre><code>&lt;HTML&gt; &lt;HEAD&gt; &lt;script&gt; //build a function named displayImage //it should be catching the value of the item selected in a variable named whichImage //use an if / else structure to test for whichImage not being equal to the string "noImage" //if the statement is true then display the selected image in the canvas image //if the statement is false then display the "blank.jpg" external file in the canvas image //In the select tag below add an onChange event handler that calls the displayImage function //the value property of the selection list should be passed to the displayImage function as it is called //hint (this.value) function displayImage(whichImage) { if(whichImage != "noImage") { document.canvas.src = whichImage; } else { document.canvas.src = "blank.jpg"; } } &lt;/script&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;form name="imageForm"&gt; &lt;table border=3&gt; &lt;tr&gt; &lt;td&gt; &lt;select name="imageSelector" onchange = "displayImage(this.value)"&gt; &lt;option value="noImage"&gt;Select an Animal &lt;option value="dog.jpg"&gt;Dog &lt;option value="cat.jpg"&gt;Cat &lt;option value="parrot.jpg"&gt;Parrot &lt;option value="fish.jpg"&gt;Fish &lt;option value="alligator.jpg"&gt;Alligator &lt;option value="mouse.jpg"&gt;Mouse &lt;option value="fox.jpg"&gt;Fox &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;img src="blank.jpg" name="canvas"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre>
    singulars
    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.
 

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