Question:

Javascript code question

by  |  earlier

0 LIKES UnLike

I am trying to add a script that will change the image of an image tag with the name "pimage" I have the following code but cannot get it to work for some reason. Could someone tell me what I am doing wrong?

$script_link = '<A HREF="" onMouseOver="document.

getElementById("pimage").src ="'. $products_image_large.'"; return true">'.$thumb_slashes.'</A>';

 Tags:

   Report

2 ANSWERS


  1. if pimage is the name rather than id then try document[&quot;pimage&quot;].src


  2. You can borrow the script from this page: http://sunshinesketches.com rename the images and documents to whatever you want.

    There&#039;s a section of script that instantiates the objects for the rollovers in the head section

    &lt;script language=&quot;JavaScript1.2&quot;&gt;

    if (document.images) {

         button1 = new Image

         button2 = new Image

       button1.src = &quot;images/YOURIMAGENAME&quot;

       button2.src = &#039;images/YOURSSECONDIMAGENAMEf&#039;

    }

    &lt;/script&gt;

    and then more in the body.

    &lt;a href=&quot;http://YOUR URL&quot; onmouseover=&quot;document.YOURNAME.src=butto... onmouseout=&quot;document.YOURNAME.src=button... src=&quot;images/YOURIMAGENAME&quot; alt=&quot;text description&quot; border=0 name=&quot;YOURNAME&quot;&gt;&lt;/a&gt;

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.