JavaScript Reference/Javascript Properties/form

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

"form" Example

    
<html>
<body>
<script language="JavaScript">
function function1(form) {
    var elem = document.getElementById("myfunction1").form.id;
    alert(elem);
    return true; 
} 
</script>
<form id="myF">
<input id="myfunction1" 
       type="button" 
       value="Get ID of this control"s form" onClick="function1(this.form);">
</form>
</body>
</html>



"form" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<button>                        <fieldset> (IE6)              |
|                |<input type="button">           <input type="checkbox">       |
|                |<input type="file">             <input type="hidden">         |
|                |<input type="image">            <input type="password">       |
|                |<input type="radio">            <input type="reset">          |
|                |<input type="submit">           <input type="text">           |
|                |<isindex>                       <label>                       |
|                |<legend>                        <object>                      |
|                |<option>                        <select>                      |
|                |<textarea>                                                    |
+----------------+--------------------------------------------------------------+



"form" Syntax and Note

Note:
Read-only property. 
Returns a reference to the <form> element. 

Value: 
An object 
null               (if the container element is not a <form>).
    
Syntax:
    
document.getElementById("elementID").form
document.all.elementID.form // IE only