javascript参考 表单元素的属性和方法 一
Checkbox
A checkbox on an HTML form. A checkbox is a toggle switch that lets the user set a value on or off.
属性
checked
A Boolean value specifying the selection state of the checkbox.
属性源 Checkbox
描述
If a checkbox button is selected, the value of its checked property is true; otherwise, it is false.
You can set the checked property at any time. The display of the checkbox button updates immediately when you set the checked property.
defaultChecked
A Boolean value indicating the default selection state of a checkbox button.
属性源 Checkbox
描述
If a checkbox is selected by default, the value of the defaultChecked property is true; otherwise, it is false. defaultChecked initially reflects whether the CHECKED attribute is used within an INPUT tag; however, setting defaultChecked overrides the CHECKED attribute.
You can set the defaultChecked property at any time. The display of the checkbox does not update when you set the defaultChecked property, only when you set the checked property. see more www.aspxuexi.com
form
An object reference specifying the form containing the checkbox.
属性源 Checkbox
描述
每个表单元素都有一个 form 属性用于指向元素的父表单。该属性在事件控制句柄中特别有用,你可能想要由其获得当前表单中其它元素。
name
A string specifying the checkbox's name.
属性源 Checkbox
描述
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 Button 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 Checkbox objects, the value of the type property is "checkbox". This property specifies the form element's type.
属性源 Checkbox
示例
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 VALUE attribute of the checkbox.
属性源 Checkbox
方法
blur
Removes focus from the checkbox.
方法源 Checkbox
语法
blur()
参数
无
click
Simulates a mouse-click on the checkbox, but does not trigger its onClick event handler. The method checks the checkbox and sets toggles its value.
方法源 Checkbox
语法
click()
参数
无。
示例
The following example toggles the selection status of the newAge checkbox on the musicForm form:
document.musicForm.newAge.click()
focus
Gives focus to the checkbox.
方法源 Checkbox
语法
focus()
参数
无
描述
Use the focus method to navigate to a the checkbox and give it focus. The user can then toggle the state of the checkbox.
handleEvent
调用指定事件的控制句柄。
语法
handleEvent(event)
参数
event 你想要调用的对象的某一事件控制句柄的名称。
from:asp学习网/title:javascript参考 表单元素的属性和方法 一/ time:2007-3-30 19:47:27
本文主题表单