Forum Moderators: open

Message Too Old, No Replies

Why don't my image buttons work?

         

petguy

1:13 am on May 20, 2004 (gmt 0)



This is the original code for the standard form buttons, which works perfectly.

<input type=submit class=submitclass name=button value="Back" onclick="javascript:history.back();">

<input type=submit class=submitclass name=add value='Add' onclick="return color_check()";>

However, I want the buttons to be rendered as images, so I did this:

<input type=image src="back.gif" name=submit value=Back onclick="javascript:history.back();">

<input type=image src="add.gif" name=submit value=Add onclick="return color_check()";>

The image buttons don't seem to do anything when clicked. What am I doing wrong here?

Rambo Tribble

5:18 am on May 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, both sets of code are pretty far from spec. Just use image tags within anchor tags to display the images and make the href value your javascript calls. Like:

<a href="javascript:history.back();"><img src="back.gif" /></a>

brucec

2:55 pm on May 21, 2004 (gmt 0)

10+ Year Member



I use a function for this, but the javascript header works too.

Rambo Tribble

1:47 am on May 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, and the onclick event handler can be used as part of the <img> tag, obviating the need for the <a> tag and the javascript: pseudo-URL, as well. I just didn't want to cloud the issue with too much information.