473,769 Members | 4,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

implement clear function using reset button

i need to implement a clear button to clear all the fields in the
form,
but i am thinking i can just use reset button.

<input type="reset" name="reset" value="CLEAR">

The first thought is that if there is default value reset and clear
will become different.
My understanding is that reset means to restore the original page
before
any edits by the user.

It seems like I can use reset button to implement clear javascript
button.

Please advise. Thanks!!
Jul 23 '05 #1
2 8091
In article <ba************ **************@ posting.google. com>,
jr********@hotm ail.com (Matt) wrote:
i need to implement a clear button to clear all the fields in the
form,
but i am thinking i can just use reset button.

<input type="reset" name="reset" value="CLEAR">

The first thought is that if there is default value reset and clear
will become different.
My understanding is that reset means to restore the original page
before
any edits by the user.

It seems like I can use reset button to implement clear javascript
button.

Please advise. Thanks!!


I can't really help you on this, but I thought I'd ask the group a more
general question:

Do you include a clear button in your forms? Why? Who would fill out a
whole form and then decide they want to clear it?
Jul 23 '05 #2
Matt wrote:
i need to implement a clear button to clear all the fields in the
form, but i am thinking i can just use reset button.

<input type="reset" name="reset" value="CLEAR">

The first thought is that if there is default value reset and clear
will become different.
My understanding is that reset means to restore the original page
before any edits by the user.
That button sets the default value for all form elements of the form.
It seems like I can use reset button to implement clear javascript
button.


It doesn't, and you shouldn't. Instead, you should use something like
the following.

J(ava)Script:

function clearForm(o)
{
if (o && o.form)
{
o = o.form;
}

var e;
if (o && (e = o.elements))
{
for (var i = 0; len = e.length, tn, ty; i < len; i++)
{
o = e[i];
if ((tn = o.tagName)
&& (ty = o.type)
&& ((tn = tn.toLowerCase( )) == "input"
&& ty.toLowerCase( ) == "text")
|| tn == "textarea")
{
o.value = "";
}
}
}
}

HTML

<form ...>
...
<input type="button" value="Clear" onclick="clearF orm(o)">
...
</form>
HTH

PointedEars
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
18479
by: Pete | last post by:
I have a site which is using sessions to pass data from one page through to the next. The problem that I have is that there are only two places where the session could/should be destroyed. This is where a form is printed using : <input type="button" name="Button" value="Print Order" onClick="window.print();"> or when the order form is reset using a JavaScript function :
5
3889
by: Matt | last post by:
I want to write a generic clearForm function to clear the form when the user click CLEAR button. Here's my attempts, because I want to take care all html controls. I think I need to test if the control is submit button, regular button. But I don't know what I should do on drop down box? function clearForm() { var i=0;
3
11681
by: Jake | last post by:
How can I have an image that when clicked would clear my textarea field? The textarea field is the only element in my form and has a default value - a couple lines of text.. I tried using a reset button but it only clears text that was just entered. TIA!
3
1481
by: Jeff User | last post by:
Greeting I built asp.net (V1.1) page. I want to use this button to reset SelectedIndex=0 on several drop down lists. However, I do not want to post back to server. The point is to avoid the round trip. It had an asp:button which would post back to the server when clicked but changed it to an input button to avoid the postback. (If that is not needed,let me know)
5
5801
by: plumba | last post by:
Ok, another query.... I have a checkbox at the bottom of my form which when checked unhides a <div> block which displays the submit button. The problem I have is when the clear form button is pressed it removes the check but does not re-hide the submit <div> bit. The way i see it, I have 3 options: 1) To simply remove the clear for button. 2) To exclude the said checkbox from the CLEAR button function. 3) To have the CLEAR button run...
1
2290
by: johnacooke | last post by:
I have a HTML form that is generated in part by PHP. The action attribute on the form tag calls itself, so that I can validate the fields without using any other form of code like Javascript to validate fields, etc. All works well; fields like e-mail addresses are correctly validated with one notable exception. The <input type="reset" ... only works the first time the form is called.
0
1409
by: paulcybulski | last post by:
OK here is my issue...I have a main map with a minimap which has a selection box that displays the current view of the main map...you can zoom by way of mouse wheel scroll, +/- buttons, and a wheel which you can click/drag and turn to zoom in and out...thats all fine and dandy, but when you zoom to the max, the selection box in the minimap is slightly shifted out of place...I have a reset function that resets to the original position and...
5
4504
by: karsagarwal | last post by:
I have a bounded form and after I click the button to update/save. THe fields are still there. Is there a way to clear off the fields in the bounded form. Thanks, SA Here's the code that I have: Private Sub cmdSave_Click()
5
2172
by: azura | last post by:
dear sir... right now i'm using flash button to create clear/reset button..unfortunatelly when upload into server, my flash button for clear/reset doesn't exist..so i try to create new one but i don't know how to create using manually.. because i had tried but it's not functioning.. so i need some help who can teach me or point me to any website that i can learn about clear/ reset button.. thanks
0
9587
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.