function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anuj Joshi 16Anuj Joshi 16 

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>
RAM AnisettiRAM Anisetti
Hi,
try to modifie your code like below
 
<apex:page >
<script>
function getimage()
{
    x=document.getElementById("theImage")
    x.style.visibility="visible";
}
</script>
 <apex:form >
 <img id="theImage" src="https://upload.wikimedia.org/wikipedia/en/3/34/SFDC_logo.png" style="visibility:hidden" width="220" height="55"/>
 <apex:commandButton value="Get Image" onclick="getimage()"/>
 </apex:form>
</apex:page>