PDA

View Full Version : button (not submit) as image?


homerUK
05-15-2003, 12:44 PM
Hey,

I checked the search, but couldnt find this solution...

I have a submit button, and a "normal" button (type="button") for use on a form... when the Submit button is pressed, it calls an event to check the form (validation) then submit it. Next to that, I have a button which is used to cancel the form. ie: when the user clicks "cancel" it moves them to another page.

This code works:


<input type="button" value="cancel" onClick="ask()">


but i tried to use this with an image....


<input type="image" src="x.gif" alt="cancel" onClick="ask()">



The image button does ask the user if they want to cancel, but if they select yes or no, it still submits the form. Basically, my question is how to I make that image work as a basic button, NOT a submit button. I guess I could move it outside the form... but I'd rather not......

any help will be much appreciated.....

thanks...

Weirdan
05-15-2003, 12:50 PM
<input type="button" value="cancel" onClick="ask();return false">

sarah
05-15-2003, 01:14 PM
you could try:

<img src="x.gif" alt="cancel" onClick="ask()">

mw22
05-15-2003, 01:17 PM
Try this:
<button><img src="imgsrc"></button>
As far as I know input type=image is by default a submit button.

requestcode
05-15-2003, 01:18 PM
An input type of image is used for submitting forms. That is why you are having problems. You might try this:
<a href="javascript:ask()"><img src="pic.gif" border="0"></a>

homerUK
05-15-2003, 02:34 PM
Thanks for all the help.... I used requestcode's idea of surrounding the image of the button with the JS function....


all the help is much appreciated!! :thumbsup: