Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryManaging Website Forms

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Using an Image Instead of a Reset Button

I'll show you how to use an image for the same functionality as a reset button.

The reset button remains in the form, but un-displayed. The image, when clicked, calls the reset button's click() function.

Working form with reset button:

a   b   c  

Working form with image instead of reset button:

a   b   c   reset the form

How To Use an Image Instead of a Reset Button

First, make your form with the reset button. Ensure it works.

For demonstration purposes, let's assume your reset button looks like this:

<input type="reset">

To implement the feature:

  1. Modify the reset button.

  2. Insert an image to use instead of the reset button.

  3. Insert an onclick attribute into the image tag.

1. Modify the reset button.

The reset button needs an id value and a CSS definition display:none;

The above example modified may look like this:

<input type="reset" id="resetbuttonid" style="display:none;">

The id value assigned to the reset button will be used in the image tag's onclick attribute (see further below).

The CSS definition display:none; un-displays the reset button. The reset button code is still there, and live, it's just not visible.

2. Insert an image to use instead of the reset button.

Insert the image to be clicked instead of the reset button. The image tag can be anywhere on the page. Consider putting it immediately before or after the un-displayed reset button source code.

Here is an example image tag (the same image used in the above working form):

<img 
   src="//www.willmaster.com/images/redo.jpg" 
   width="50" 
   height="46" 
   alt="reset the form" 
   title="Click to reset the form.">

3. Insert an onclick attribute into the image tag.

An onclick attribute needs to be inserted into the image img tag. Here is the format:

onclick="document.getElementById('IDHERE').click()"

Replace "IDHERE" with the id of the reset button. In the above example reset button code, the id is "resetbuttonid". Thus:

onclick="document.getElementById('resetbuttonid').click()"

Here is the above image img tag with the onclick attribute inserted:

<img 
   onclick="document.getElementById('resetbuttonid').click()" 
   src="//www.willmaster.com/images/redo.jpg" 
   width="50" 
   height="46" 
   alt="reset the form" 
   title="Click to reset the form.">

You Are Good To Go

With the above steps in place, clicking the image will do what the reset would have done. It has the same functionality.

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List
software index page

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC