reset object
A reset button on an htm form. A reset button resets all elements in a form to their defaults.
语法
To define a reset button, use standard htm 语法 with the addition of the onClick event handler:
<INPUT TYPE="reset" NAME="resetName" VALUE="buttonText" [onClick="handlerText"]>
NAME="resetName" specifies the name of the reset object. You can access this value using the name property. VALUE="buttonText" specifies the text to display on the button face. You can access this value using the value property.
To use a reset object's properties and 用法:
1. resetName.propertyName 2. resetName.methodName(parameters) 3. formName.elements[index].propertyName 4. formName.elements[index].methodName(parameters)
resetName is the value of the NAME attribute of a reset object. formName is either the value of the NAME attribute of a form object or an element in the forms array. index is an integer representing a reset object on a form. propertyName is one of the properties listed below. methodName is one of the 用法 listed below.
Property of
form描述
A reset object on a form looks as follows:
A reset object is a form element and must be defined within a <FORM> tag.
The reset button's onClick event handler cannot prevent a form from being reset; once the button is clicked, the reset cannot be canceled.
Properties
name reflects the NAME attribute value reflects the VALUE attribute用法
clickEvent handlers
onClick例子
Example 1. The following example displays a text object with the default value "CA" and a reset button with the text "Clear Form" displayed on its face. If the user types a state abbreviation in the text object and then clicks the Clear Form button, the original value of "CA" is restored.
<B>State: </B><INPUT TYPE="text" NAME="state" VALUE="CA" SIZE="2">
<P><INPUT TYPE="reset" VALUE="Clear Form">
Example 2. The following example displays two text objects, a select object, and three radio buttons; all of these objects have default values. The form also has a reset button with the text "Defaults" on its face. If the user changes the value of any of the objects and then clicks the Defaults button, the original values are restored.
<htm>
<HEAD>
<TITLE>Reset object example</TITLE>
</HEAD>
<BODY>
<FORM NAME="form1">
<BR><B>City: </B><INPUT TYPE="text" NAME="city" VALUE="Santa Cruz" SIZE="20">
<B>State: </B><INPUT TYPE="text" NAME="state" VALUE="CA" SIZE="2">
<P><SELECT NAME="colorChoice">
<OPTION SELECTED> Blue
<OPTION> Yellow
<OPTION> Green
<OPTION> Red
</SELECT>
<P><INPUT TYPE="radio" NAME="musicChoice" VALUE="soul-and-r&b"
CHECKED> Soul and R&B
<BR><INPUT TYPE="radio" NAME="musicChoice" VALUE="jazz">
Jazz
<BR><INPUT TYPE="radio" NAME="musicChoice" VALUE="classical">
Classical
<P><INPUT TYPE="reset" VALUE="Defaults" NAME="reset1">
</FORM>
</BODY>
</htm>
本文详细介绍了HTML中重置按钮的使用方法及其属性,包括如何定义重置按钮、其作用及事件处理等内容,并通过实例展示了如何利用重置按钮将表单元素恢复到默认状态。
1610

被折叠的 条评论
为什么被折叠?



