SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript OnMouseOver Help

    Hi, I was wondering if you could help me change an image on a form submit button.
    I have used OnMouseOver with links but I want to use it with a form button.
    Here is what I have:
    PHP Code:
    <script language="JavaScript">
    <!-- 
    Begin
    if (document.images)
       {
         
    submiton= new Image(70,20);
         
    submiton.src="images/loginb1.gif";
         
    submitoff= new Image(70,20);
         
    submitoff.src="images/loginb.gif";
       }
    function 
    lightup(imgName)
     {
       if (
    document.images)
        {
          
    imgOn=eval(imgName "on.src");
          
    document[imgName].srcimgOn;
        }
     }

    function 
    turnoff(imgName)
     {
       if (
    document.images)
        {
          
    imgOff=eval(imgName "off.src");
          
    document[imgName].srcimgOff;
        }
     }
    // End -->
    </script>
    </HEAD>
    ////////// Further Down...

        <input type="image" src="images/loginb.gif" name="submit" value="submit" onMouseover="lightup('submit')" onMouseout="turnoff('submit')">
    </td></tr></table></form> 
    What am I doing wrong?

    Thanks,
    ~Rhys

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You really don't need all that code to switch an image. Here's a way to do it very simply:

    Code:
    <input type="image" src="images/loginb.gif" onmouseover="this.src='images/loginb1.gif';" onmouseout="this.src='images/loginb.gif';">

  3. #3
    SitePoint Guru TacMaf's Avatar
    Join Date
    Dec 2005
    Location
    Manchester, United Kingdom
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow thanks jim!


Bookmarks

Posting Permissions

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