--- title: Document.forms slug: Web/API/Document/forms tags: - Forms translation_of: Web/API/Document/forms ---
{{APIRef("DOM")}}

forms는 현재 document에 존재하는 {{HTMLElement("form")}} element 들이 담긴 collection (an {{domxref("HTMLCollection")}})을 반환합니다.

Syntax

collection = document.forms;

Example: Getting form information

<!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>

Example 2:Getting an element from within a form

var selectForm = document.forms[index];
var selectFormElement = document.forms[index].elements[index];

Specifications

Specification Status Comment
{{SpecName('HTML WHATWG', '#dom-document-forms', 'Document.forms')}} {{ Spec2('HTML WHATWG') }}  
{{SpecName('DOM2 HTML', 'html.html#ID-1689064', 'Document.forms')}} {{ Spec2('DOM2 Events') }} Initial definition.

See also