blob: 675110bb47015a83ac68dbde1e116ec50bbda696 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
---
title: Document.forms
slug: Web/API/Document/forms
tags:
- Forms
translation_of: Web/API/Document/forms
---
<div>{{APIRef("DOM")}}</div>
<p><code>forms</code>는 현재 document에 존재하는 {{HTMLElement("form")}} element 들이 담긴 collection (an {{domxref("HTMLCollection")}})을 반환합니다.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox"><var>collection</var> = document.forms;</pre>
<h2 id="Example" name="Example">Example: Getting form information</h2>
<pre class="brush:html"><!DOCTYPE html>
<html lang="en">
<head>
<title>document.forms example</title>
</head>
<body>
<form id="robby">
<input type="button" onclick="alert(document.forms[0].id);" value="robby's form" />
</form>
<form id="dave">
<input type="button" onclick="alert(document.forms[1].id);" value="dave's form" />
</form>
<form id="paul">
<input type="button" onclick="alert(document.forms[2].id);" value="paul's form" />
</form>
</body>
</html>
</pre>
<h2 id="Example_2Getting_an_element_from_within_a_form">Example 2:Getting an element from within a form</h2>
<pre class="brush: js">var selectForm = document.forms[index];
var selectFormElement = document.forms[index].elements[index];
</pre>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('HTML WHATWG', '#dom-document-forms', 'Document.forms')}}</td>
<td>{{ Spec2('HTML WHATWG') }}</td>
<td> </td>
</tr>
<tr>
<td>{{SpecName('DOM2 HTML', 'html.html#ID-1689064', 'Document.forms')}}</td>
<td>{{ Spec2('DOM2 Events') }}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="See_Also" name="See_Also">See also</h2>
<ul>
<li>{{domxref("HTMLFormElement")}}</li>
</ul>
|