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

How to change apex:image on mouseover
I am fairly new to Html/VisualForce so maybe this is an obvious question but how does one change the image associated with an apex:image element on a VisualForce page when the user places the mouse over it?
That did not work exactly as you put in your reply BUT it gave me enough of clue to figure out what does work. Maybe not the most efficient but it works. THANK YOU for the assistance.
Code that worked for me:
. . . <apex:image url="{!$Resource.MyNormal}" width="100" height="100" id="MyImage" onmouseover="ImageOver(this)" onmouseout="ImageNormal(this)" /> . . . <script type="text/javascript"> function ImageOver(MyImage) { MyImage.src='{!$Resource.MyOver}'; } function ImageNormal(MyImage) { MyImage.src='{!$Resource.MyNormal}'; } </script>
All Answers
You can just use standard javascript. There's an onmouseover event that fires for apex:image
<apex:image onmouseover='nameOfJavaScriptFunction'...
I saw that but the problem is I do not know how to change the specific image in an apex:image. For example. I have the following VF code:
<apex:image url="{!$Resource.MyNormalImage}" width="100" height="100" id="MyImage" />
and on mouse over I would like to chnage the image to the file in the static resources called MyHoverImage. Could you give me an example of how to do that?
Thanks
<script>
function changeImage()
{
this.src='{!$Resource.MySecondImage}';
}
</script>
<apex:image url="{!$Resource.MyNormalImage}" width="100" height="100" id="MyImage" onmouseover="changeImage(this)"/>
I have not tested it. Give it a try.
That did not work exactly as you put in your reply BUT it gave me enough of clue to figure out what does work. Maybe not the most efficient but it works. THANK YOU for the assistance.
Code that worked for me:
. . . <apex:image url="{!$Resource.MyNormal}" width="100" height="100" id="MyImage" onmouseover="ImageOver(this)" onmouseout="ImageNormal(this)" /> . . . <script type="text/javascript"> function ImageOver(MyImage) { MyImage.src='{!$Resource.MyOver}'; } function ImageNormal(MyImage) { MyImage.src='{!$Resource.MyNormal}'; } </script>