Results 1 to 2 of 2

Thread: onclick

  1. #1
    Corin Guest

    Default onclick

    I would like to switch images with an onclick of the same image. For example I have a red box and when you click on it it turns yellow. When you click on it again it returns to red. <BR><BR>Can anyone help?

  2. #2
    Nathan Pond Guest

    Default RE: onclick

    This is javascript... give the image a name:<BR><BR>&#060;img src=red.gif name=colorimg onClick=changeImage()&#062;<BR><BR>and write the function:<BR><BR>function changeImage(){<BR> if (colorimg.src="red.gif")<BR> colorimg.src="yellow.gif";<BR> else<BR> colorimg.src="red.gif";<BR>}<BR><BR><BR>note that it&#039s been awhile since I&#039ve done this and I just pulled that off the top of my head, so I may have forgotten something. Let me know if it doesn&#039t work.<BR><BR>Nathan Pond

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts