dumdumsareyum Posted April 11, 2008 Share Posted April 11, 2008 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 https://forums.phpfreaks.com/topic/100574-swap-images-for-form-button/ Share on other sites More sharing options...
Psycho Posted April 11, 2008 Share Posted April 11, 2008 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 https://forums.phpfreaks.com/topic/100574-swap-images-for-form-button/#findComment-514895 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.