Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Onclick function for both pictures and sounds

Status
Not open for further replies.

jemmsey

Programmer
Mar 17, 2006
1
GB
Hi,

I'm trying to use the Onclick function to click on one image so another one is shown in the same place and a sound is played. Any ideas?

Thanks
 
Do you mean that you want to have an image, that when clicked, replaces itself with another image and plays a sound? If so, it shouldn't be that hard.

I haven't tested this code but you could give it a try:
Code:
<script language="Javascript" type="text/javascript">
function changeme(cimage)
{
   cimage.src="secondbla.gif";
   return true;
}
</script>

and in the html

Code:
<img src="bla.gif" onclick="changeme(this);">

I'm not sure how to insert sound, but I'm sure you can find that somewhere, then you would just stick it in the javascript function.

-Kerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top