JavaScript Tutorial/Form/Hidden Object — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 11:24, 26 мая 2010

Hidden

The Hidden object is created with the HTML <input> tag. Specifying the TYPE parameter of the <input> tag as hidden creates the Hidden object. It is a text object that is suppressed from form display in an HTML form. The Hidden object is primarily used for passing name/value pairs from a form.

Property Description form Specifies the form containing the Hidden object. name Refers to the name of Hidden object. type Refers to HTML TYPE attribute of Hidden object. value Refers to HTML VALUE attribute of Hidden object.



   <source lang="javascript">

<html>

   <head>
   <title> Creating hidden objects</title>
   </head>
   <body>
   <form name="form1">
   <input type="hidden" name="hide1" value="Test">

<input type="button" value="Get Hidden Attributes" onClick="alert(form1.hide1.name + " " + form1.hide1.type + " " + form1.hide1.value)"> </form> </body> </html></source>

Hidden.form

<p>The form property of the Hidden object is used to reference the form containing the Hidden object.



   <source lang="javascript">

<html>

   <head>
   <title> Using the form property of the Hidden object</title>
   </head>
   <body>
   <form name="form1">
   Form name:<input type="hidden" name="hide1" value="Test">

<input type="button" value="Form Name" onClick="this.form.hide1.value=this.form.name"> </form> </body> </html></source>

Hidden.name

<p>The name property is used get the name for the Hidden object.

This is the HTML NAME attribute for the Hidden object.



   <source lang="javascript">

<html>

   <head>
   <title> Using the name property of the Hidden object</title>
   </head>
   <body>
   <form name="form1">
   Form name:<input type="hidden" name="hide1" value="Test">

<input type="button" value="Hidden Name" onClick="alert("The Hidden object name is: " + form1.hide1.name)"> </form> </body> </html></source>

Hidden.type

<p>The type property specifies the hidden type.

For all Hidden objects, the type value is Hidden.



   <source lang="javascript">

<html>

   <head>
   <title> Using the type property of the Hidden object</title>
   </head>
   <body>
   <form name="form1">
   Form name:<input type="hidden" name="hide1" value="Test">

<input type="button" value="Hidden Type" onClick="alert("The Hidden object type is: " + form1.hide1.type)"> </form> </body> </html></source>

Hidden.value

<p>The value property reflects the HTML VALUE attribute of the Hidden object.



   <source lang="javascript">

<html>

   <head>
   <title> Using the value property of the Hidden Object</title>
   </head>
   <body>
   <form name="form1">
   Form name:<input type="hidden" name="hide1" value="Test">

<input type="button" value="Get Hidden Value" onClick="alert("The Hidden object value is: " + form1.hide1.value)"> </form> </body> </html></source>