Using PHP on reset button to clear html/PHP form

How do I use a button to reset a form.
Just like the submit button, I have a reset button but when I click it the form does not clear.

I am actually using an image for the button, like this.

<input name=“reset” type=“image” src=“images/reset_button.jpg” class=“reset_button” />

The form is process with a PHP script but the reset does not work

Any help will be greatly appreciated.


<input name="reset" type="image" src="images/reset_button.jpg" class="reset_button" />

try this

<input name="reset" type="reset" src="images/reset_button.jpg" class="reset_button" />

Thanks very much for the time and efforts, however, it did not work, when I enter the code or did as you indicated, the image is replace with an html default button.

So now how do you do this without losing the image. By changing the type to image, it removes the image and replaces it with a html button.

Another other ideas.


Generally there is no way of doing that with reset button as far as i know. But you should write some css or some javascript function to trigger when the normal image/link is clicked which clears all the fields of the form.

See this:

Try this

<input name="reset" type="image" src="images/reset_button.jpg" class="reset_button" onclick="document.theForm.reset();return false;" />

or you can check this link

I’d recommend using a checkbox instead of a button. A button must be in down state for PHP to receive it’s value when it’s clicked - typically this is only going to occur for the submit button - unless you want the form immediately submitted when the reset button is hit.

Simply reset(); is sufficient.

<input name="reset" type="image" src="images/reset_button.jpg" class="reset_button" onclick="reset();" />

The reason is the form to be reset is already in the scope of the button they’re interacting with. You don’t need to restate the path if you don’t want (tightens the code and lessens the chance of error though).

Well I applied this but it does not work.

The PHP form I have is a quote form, so nothing is actually being submitted to a database or e-mail address.

You put in information, click submit and get a quote.

The form clears fine if you select information and then click the reset button
But when you submit the information, you get a quote but the form does not clear - this is why I use the reset button to clear or reset the form.

But the form does not reset or clear after you have submit it.