View Full Version : can i use an image as reset button ?

12-04-2002, 11:20 PM
i know i can use an image as a submit button, but can i use one as a reset button ?



12-04-2002, 11:28 PM
i am almost positive the syntax is like this
<img src="rst.jpg" type="submit">

12-05-2002, 12:50 AM
well .. i know the syntax for submit button as an image ... and it actually goes like this ...

<input type='image' name='submit' value="submit" src='image.gif" border="0">

the question is .. if and how can i use a button to clear a form.


Roy Sinclair
12-05-2002, 03:12 PM
<form name="myform">


<a href="Reset the form" onclick="document.forms["myform"].reset();return false;"><img src="myresetimage" /></a>
Since you don't have Javascript enabled, use only this button to reset the form <input type="reset" value="Reset the Form Here" />

12-05-2002, 03:35 PM

the code works fine ... there is only one problem ... when the page loads everything worksfine ..but when i press reset .. and page resets .... i get an error message from javascript.

Line: 122
Char: 1
Error: Syntax Error
Code: 0
URL: www.mypage.com/contact.php

And line 122 is empty ...

any idea why this might be happening ?


Roy Sinclair
12-05-2002, 04:10 PM
I can't tell without seeing the code but as a first guess I'd suspect that you've got a typo. My usual problem is spelling false as flase :)

12-09-2002, 07:14 AM
use single quotes instead:

<a href="Reset the form" onclick="document.forms['myform'].reset();return false;"><img src="myresetimage" /></a>

12-09-2002, 10:45 AM
A general debugging tip for javascript (and php): the error may not become apparent until a few lines after you entered it. This is especially true of missing quotes (something I keep doing, so I know this well). If you get an error on a line, look backwards from that line for a problem.

Since the answer's already posted, I probably didn't need to add that.

12-09-2002, 11:35 AM

<button type="reset"><img src="pic.jpg"></button> :D