Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.arcetri.astro.it/irlab/doc/library/javascript/clientreference/hidden.htm
Дата изменения: Thu Oct 7 13:13:38 1999 Дата индексирования: Sat Dec 22 14:24:01 2007 Кодировка: Поисковые слова: п п п п п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п |
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.INPUT
tag, with "hidden"
as the value of the TYPE
attribute. For a given form, the JavaScript runtime engine creates appropriate Hidden
objects and puts these objects in the elements
array of the corresponding Hidden
object. You access a Hidden
object by indexing this array. You can index the array either by number or, if supplied, by using the value of the NAME
attribute.
Hidden
object is a form element and must be defined within a FORM
tag.
A Hidden
object cannot be seen or modified by an end user, but you can programmatically change the value of the object by changing its value
property. You can use Hidden
objects for client/server communication.
Property |
Description
|
|
|
| |
---|
watch
and unwatch
methods from Object
.
Hidden
object to store the value of the last object the user clicked. The form contains a "Display hidden value" button that the user can click to display the value of the Hidden
object in an Alert dialog box.
<HTML>
<HEAD>
<TITLE>Hidden object example</TITLE>
</HEAD>
<BODY>
<B>Click some of these objects, then click the "Display value" button
<BR>to see the value of the last object clicked.</B>
<FORM NAME="myForm">
<INPUT TYPE="hidden" NAME="hiddenObject" VALUE="None">
<P>
<INPUT TYPE="button" VALUE="Click me" NAME="button1"
onClick="document.myForm.hiddenObject.value=this.value">
<P>
<INPUT TYPE="radio" NAME="musicChoice" VALUE="soul-and-r&b"
onClick="document.myForm.hiddenObject.value=this.value"> Soul and R&B
<INPUT TYPE="radio" NAME="musicChoice" VALUE="jazz"
onClick="document.myForm.hiddenObject.value=this.value"> Jazz
<INPUT TYPE="radio" NAME="musicChoice" VALUE="classical"
onClick="document.myForm.hiddenObject.value=this.value"> Classical
<P>
<SELECT NAME="music_type_single"
onFocus="document.myForm.hiddenObject.value=this.options[this.selectedIndex].text">
<OPTION SELECTED> Red <OPTION> Orange <OPTION> Yellow
</SELECT>
<P><INPUT TYPE="button" VALUE="Display hidden value" NAME="button2"
onClick="alert('Last object clicked: ' + document.myForm.hiddenObject.value)">
</FORM>
</BODY>
</HTML>
document.cookie
form
property that is a reference to the element's parent form. This property is especially useful in event handlers, where you might need to refer to another element on the current 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">Example 2. The following example uses an object reference, rather than the
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>
this
keyword, to refer to a form. The code returns a reference to myForm
, which is a form containing myHiddenObject
.
document.myForm.myHiddenObject.form
Hidden
Hidden
objects, the value of the type
property is "hidden"
. This property specifies the form element's type. 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
attribute of the object.value
property of a group of buttons and displays it in the msgWindow
window:
function valueGetter() {This example displays the following values:
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()
}
The submit button says Query SubmitThe previous example assumes the buttons have been defined as follows:
The reset button says Reset
The hidden field says pipefish are cute.
<INPUT TYPE="submit" NAME="submitButton">
<INPUT TYPE="reset" NAME="resetButton">
<INPUT TYPE="hidden" NAME="hiddenField" VALUE="pipefish are cute.">
Last Updated: 05/28/99 11:59:34