Form Object
表单对象
The Form object represents an HTML form. For each instance of an HTML <form> tag in a document, a Form object is created.
表单对象代表一个HTML表单。HTML中一有<form>标签,一个表单对象就被建立了。
Forms are used to prompt users for input. The input data is normally posted to a server for processing.
表单被用来提示用户输入。输入的数据一般被发送到服务器上做处理
IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).
Form Object Collections表单对象集合
Collection 集合 | Description 描述 | IE | F | N | W3C |
---|---|---|---|---|---|
elements[] | Returns an array containing each element in the form 返回包含表单中每个元素的数组 | 3 | 1 | 2 | Yes |
Form Object Properties表单对象属性
Property 属性 | Description 描述 | IE | F | N | W3C |
---|---|---|---|---|---|
acceptCharset | Sets or returns a list of character encodings for form data that must be accepted by the server processing the form 设置或获取处理表单的服务器必须接受的输入数据所用的字符编码方式列表。 | 3 | Yes | ||
action | Sets or returns the URL of where the input data will be submitted 设置或返回将被提交的输入数据的URL | 3 | 1 | 2 | Yes |
encoding | Sets or returns the MIME encoding for the form | 3 | 1 | 2 | No |
enctype | Sets or returns the MIME encoding for the form 返回或设置表单的MIME编码 | 5 | 1 | 6 | Yes |
id | Sets or returns the id of the form (In IE 4 this property is read-only) | 4 | 1 | No | |
length | Returns the number of elements in a form | 3 | 1 | 2 | Yes |
method | Sets or returns how form data is submitted to the server ("get" or "post") 设置或返回数据提交给服务器的方式("get"或 "post") | 3 | 1 | 2 | Yes |
name | Sets or returns the name of a form 返回或设置表单的名称 | 5 | No | ||
target | Sets or returns the target window or frame that responses are sent to after submission of a form 设置或获取目标内容要显示于哪个窗口或框架。 | 3 | 1 | 2 | Yes |
Form Object Methods表单对象方法
Method | Description | IE | F | N | W3C |
---|---|---|---|---|---|
reset() | Resets the default values of all elements in the form (same as clicking the Reset button) 重置所有表单内元素为默认值 | 4 | 1 | 3 | Yes |
submit() | Submits the form (same as clicking the Submit button) 提交表单 | 3 | 1 | 2 | Yes |
Form Object Events表单对象事件
Syntax: object.event_name="someJavaScriptCode"
语法: object.event_name="someJavaScriptCode"
Event | Description | IE | F | N | W3C |
---|---|---|---|---|---|
onReset | Executes some code when a Reset event occurs | 4 | 1 | 3 | |
onSubmit | Executes some code when a Submit event occurs | 3 | 1 | 2 |