Sunday, 15 May 2011

javascript - How to show something under a particular situation -


I have done so far:

  & lt; Form & gt; Select image: & lt; Select ID = "Artwork" & gt; & Lt; Options & gt; Image 1 & lt; / Options & gt; & Lt; Options & gt; Image 2 & lt; / Options & gt; & Lt; Options & gt; Image 3 & lt; / Options & gt; & Lt; Options & gt; Image 4 & lt; / Options & gt; & Lt; Options & gt; Image 5 & lt; / Options & gt; & Lt; / Select & gt; & Lt; Input id = "turnin" class = "turnin" type = "button" value = "upload" onclick = "start ()"> & Lt; / Form & gt; & Lt; Script type = "text / javascript" & gt; & Lt ;! - Start the function () {var select = document.getElementById ('Artwork'); Select Var = selected. Options [select. Selected index] .text; $ ('# Blah'). Prepaid ('& lt; img id = "image_2" src = "image2.jpg" /> & gt;'); }; // -> & Lt; / Script & gt;   

However, I need

  $ ('# blah'). Prepaid ('& lt; img id = "image_2" src = "image2.jpg" /> & gt;');   

Only the option "image 2" occurs when the part is effective, what is there any way to do this?

EDIT: If there is any method then it will also be useful that the button works only once.

start function () {var select = document.getElementById ('artwork'); If ($ (select) .val () === 'Image 2') {$ ('# blah'). Prepaid ('& lt; img id = "image_2" src = "image2.jpg" /> & gt;'); }}

No comments:

Post a Comment