asp学习网: 首页 >> javascript教程 >> javascript基础 >> javascript参考 表单元素的属性和方法 二

javascript参考 表单元素的属性和方法 二

Reset
A reset button on an HTML form. A reset button resets all elements in a form to their defaults.

 


属性
form
An object reference specifying the form containing the reset button.
属性源 Reset
只读

描述
每个表单元素都有一个 form 属性用于指向元素的父表单。该属性在事件控制句柄中特别有用,你可能想要由其获得当前表单中其它元素。


name
A string specifying the name of the reset button.
属性源 Reset


描述
The value of the name property initially reflects the value of the NAME attribute. Changing the name property overrides this setting.
Do not confuse the name property with the label displayed on the reset button. The value property specifies the label for this button. The name property is not displayed on the screen; it is used to refer programmatically to the button.

If multiple objects on the same form have the same NAME attribute, an array of the given name is created automatically. Each element in the array represents an individual Form object. Elements are indexed in source order starting at 0. For example, if two Text elements and a Reset element on the same form have their NAME attribute set to "myField", an array with the elements myField[0], myField[1], and myField[2] is created. You need to be aware of this situation in your code and know whether myField refers to a single element or to an array of elements.


示例
In the following example, the valueGetter function uses a for loop to iterate over the array of elements on the valueTest form. The msgWindow window displays the names of all the elements on the form:
newWindow=window.open("http://home.netscape.com") function valueGetter() {
var msgWindow=window.open("")
for (var i = 0; i < newWindow.document.valueTest.elements.length; i++) {
msgWindow.document.write(newWindow.document.valueTest.elements[i].name + "<BR>")
}
}

type
For all Reset objects, the value of the type property is "reset". This property specifies the form element's type.
属性源 Reset
只读

示例
The following example writes the value of the type property for every element on a form.
for (var i = 0; i < document.form1.elements.length; i++) {
document.writeln("<BR>type is " + document.form1.elements[i].type)
}

value
A string that reflects the reset button's VALUE attribute.
属性源 Reset
只读

=================www.aspxuexi.com====================
描述
This string is displayed on the face of the button. When a VALUE attribute is not specified in HTML, the value property is the string "Reset".
Do not confuse the value property with the name property. The name property is not displayed on the screen; it is used to refer programmatically to the button.


示例
The following function evaluates the value property of a group of buttons and displays it in the msgWindow window:
function valueGetter() {
var msgWindow=window.open("")
msgWindow.document.write("submitButton.value is " +
document.valueTest.submitButton.value + "<BR>")
msgWindow.document.write("resetButton.value is " +
document.valueTest.resetButton.value + "<BR>")
msgWindow.document.write("helpButton.value is " +
document.valueTest.helpButton.value + "<BR>")
msgWindow.document.close()
} This example displays the following values:

Query Submit
Reset
Help The previous example assumes the buttons have been defined as follows,www.aspxuexi.com:

<INPUT TYPE="submit" NAME="submitButton">
<INPUT TYPE="reset" NAME="resetButton">
<INPUT TYPE="button" NAME="helpButton" VALUE="Help">

 


 

方法

blur
Removes focus from the reset button.
方法源 Reset

语法
blur()
参数


示例
The following example removes focus from the reset button userReset:
userReset.blur() This example assumes that the button is defined as

<INPUT TYPE="reset" NAME="userReset">


click
Simulates a mouse-click on the reset button, but does not trigger an object's onClick event handler.
方法源 Reset

语法
click()
参数


focus
Navigates to the reset button and gives it focus.
方法源 Reset

语法
focus()
参数


handleEvent
调用指定事件的控制句柄。
方法源 Reset


语法
handleEvent(event)
参数
event 你想要调用的对象的某一事件控制句柄的名称。

 

from:asp学习网/title:javascript参考 表单元素的属性和方法 二/ time:2007-3-30 20:26:53

本文主题表单元素

javascript参考 表单元素的属性和方法 一

asp教程 ©2006-2007 aspxuexi.com | 关于站点 | 版权隐私 | 站内搜索
复制或者翻版 请于夜间进行