Jump to content

swap images for form button


dumdumsareyum

Recommended Posts

I would like to change the image i'm using for a form button when it's moused over (I would like it to match my navigation link buttons)  I was trying something like this:

<input type="image" src="images/button-addCart.gif" alt="Add to Cart" title="Add to Cart" name="cartButton" id="cartButton" onMouseOver="change_it('cartButton', 'cartButtonHover')">

 

where the "change_it" function looks like this:

function change_it(initial, swap)
   {
    if(document.images)
     {
     document.images[initial].src=eval(swap + ".src");
     }
    }

 

 

but using it for an image link....so, is there a way to do this for a form button img instead of a link? or with css?

Link to comment
Share on other sites

Change the function calls to the format (this, 'path/to/image.gif')

 

<input type="image" src="images/button-addCart.gif" alt="Add to Cart"
       title="Add to Cart" name="cartButton" id="cartButton"
       onMouseOver="change_it(this, 'images/cartButton.gif')"
       onMouseOut="change_it(this, 'images/button-addCart.gif')">

 

function change_it(fieldObj, imgSrc)
{
    if(document.images)
    {
        fieldObj.src = imgSrc;
    }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.