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

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


Hidden
A Text object that is suppressed from form display on an HTML form. A Hidden object is used for passing name/value pairs when a form submits.

 


属性
form
An object reference specifying the form containing this object.
方法源 Hidden
只读


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

示例
示例 1. In the following example, the form myForm contains a Hidden object and a button. When the user clicks the button, the value of the Hidden object is set to the form's name. The button's onClick event handler uses this.form to refer to the parent form, myForm.
<FORM NAME="myForm">
Form name:<INPUT TYPE="hidden" NAME="h1" VALUE="Beluga">
<P>
<INPUT NAME="button1" TYPE="button" VALUE="Store Form Name"
onClick="this.form.h1.value=this.form.name">
</FORM> 示例 2. The following example uses an object reference, rather than the this keyword, to refer to a form. The code returns a reference to myForm, which is a form containing myHiddenObject.

document.myForm.myHiddenObject.form


name
A string specifying the name of this object.
方法源 Hidden

type
For all Hidden objects, the value of the type property is "hidden". This property specifies the form element's type.
方法源 Hidden
只读


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

value
A string that reflects the VALUE attribute of the object.

示例
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("The submit button says " +
document.valueTest.submitButton.value + "<BR>")
msgWindow.document.write("The reset button says " +
document.valueTest.resetButton.value + "<BR>")
msgWindow.document.write("The hidden field says " +
document.valueTest.hiddenField.value + "<BR>")
msgWindow.document.close()
} This example displays the following values:

The submit button says Query Submit
The reset button says Reset
The hidden field says pipefish are cute. The previous example assumes the buttons have been defined as follows:

<INPUT TYPE="submit" NAME="submitButton">
<INPUT TYPE="reset" NAME="resetButton">
<INPUT TYPE="hidden" NAME="hiddenField" VALUE="pipefish are cute.">

from:asp学习网/title:javascript参考 表单元素的属性和方法 一/ time:2007-3-30 19:47:27

本文主题表单

语义化——表单

ASp表单项目的数据传送的例子

使用快捷键提交表单的方法

设计个性化表单的五个技巧

表单中使用颜色选择器(IE)

利用userData实现客户端保存表单数据

表单元件在说什么?---分析表单元件的语义

常用表单格式的五点技巧

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