Hidden object (Object/DOM)

A field of data submitted with the form but not visible to the user.

Availability:

DOM level - 1
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Opera - 3.0
Inherits from:Input object
JavaScript syntax:-myHidden = myDocument.aFormName.anElementName
-myHidden = myDocument.aFormName.elements[anItemIndex]
IEmyHidden = myDocument.all.anElementID
IEmyHidden = myDocument.all.tags("INPUT")[anIndex]
IEmyHidden = myDocument.all[aName]
-myHidden = myDocument.forms[aFormIndex].anElementName
-myHidden = myDocument.forms[aFormIndex].elements[anItemIndex]
-myHidden = myDocument.getElementById(anElementID)
-myHidden = myDocument.getElementsByName(aName)[anIndex]
-myHidden = myDocument.getElementsByTagName("INPUT")[anIndex]
HTML syntax:<INPUT TYPE="hidden">
Argument list:anIndexA valid reference to an item in the collection
aNameThe NAME attribute of an element
anElementIDThe ID attribute of an element
anItemIndexA valid reference to an item in the collection
aFormIndexA reference to a particular form in the forms collection
Object properties:type, value
Event handlers:onAfterUpdate, onBeforeUpdate, onHelp, onRowEnter, onRowExit

Many properties, methods and event handlers are inherited from the Input object class. Refer to topics grouped with the "Input" prefix for details of common functionality across all sub-classes of the Input object super-class.

There isn't really a Hidden object class but it is helpful when trying to understand the wide variety of input element types if we can reduce the complexity by discussing only the properties and methods of a hidden field. In actual fact, the object is represented as an item of the Input object class.

Hidden objects don't respond to any events. They can't since they are not visible and therefore the user cannot interact with them to trigger one.

They may be accessed by event handling functions associated with the Form object but very little else.

Unlike MSIE, Netscape does not support the defaultValue property for this sub-class of the Input object. It also does not support the onFocus event, although why MSIE should support focus control onto a Hidden object is not clear.

Example code:

   <HTML>
   <HEAD>
   </HEAD>
   <BODY>
   <DIV ID="RESULT">?</DIV>
   <FORM>
      <INPUT TYPE="hidden" VALUE="A" NAME="BOX_A">
      <INPUT TYPE="hidden" VALUE="B" NAME="BOX_B">
      <INPUT TYPE="hidden" VALUE="C" NAME="BOX_C">
      <INPUT TYPE="hidden" VALUE="D" NAME="BOX_D">
      <INPUT TYPE="button" VALUE="Reveal" onClick="handleClick()">
   </FORM>
   <SCRIPT>
   function handleClick()
   {
      myString  = "[";
      myString += document.forms[0].BOX_A.value;
      myString += "] [";
      myString += document.forms[0].BOX_B.value;
      myString += "] [";
      myString += document.forms[0].BOX_C.value;
      myString += "] [";
      myString += document.forms[0].BOX_D.value;
      myString += "]";
      document.all.RESULT.innerText = myString;
   }
   </SCRIPT>
   </BODY>
   </HTML>

See also:Element object, Form.elements[], Input object

PropertyJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
type1.1 1.13.0 3.03.0 3.04.0 4.03.0 3.0 n/a n/a1 1 n/a n/aReadOnly.
value1.0 1.01.0 1.02.0 2.03.02 3.023.0 3.0 n/a n/a1 1 n/a n/a-

Event nameJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
onAfterUpdate n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
onBeforeUpdate n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
onHelp n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aWarning
onRowEnter n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
onRowExit n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-

Inheritance chain:

Element object, Input object, Node object