You need to sign in to do that
Don't have an account?

Inserting an image when a button is clicked
Hi,
I want to insert an image when a button is clicked in visualforce page. Here is my code. Can anyone help me to find out what is wrong with the code?
<apex:page >
<script>
function getimage()
{
<img id="theImage" src="https://upload.wikimedia.org/wikipedia/en/3/34/SFDC_logo.png" width="220" height="55"/>
}
</script>
<apex:form >
<apex:commandButton value="Get Image" onclick="getimage()"/>
</apex:form>
</apex:page>
I want to insert an image when a button is clicked in visualforce page. Here is my code. Can anyone help me to find out what is wrong with the code?
<apex:page >
<script>
function getimage()
{
<img id="theImage" src="https://upload.wikimedia.org/wikipedia/en/3/34/SFDC_logo.png" width="220" height="55"/>
}
</script>
<apex:form >
<apex:commandButton value="Get Image" onclick="getimage()"/>
</apex:form>
</apex:page>
try to modifie your code like below