diff options
Diffstat (limited to 'files/it/web/api/document/forms/index.html')
| -rw-r--r-- | files/it/web/api/document/forms/index.html | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/files/it/web/api/document/forms/index.html b/files/it/web/api/document/forms/index.html new file mode 100644 index 0000000000..cda3146a42 --- /dev/null +++ b/files/it/web/api/document/forms/index.html @@ -0,0 +1,128 @@ +--- +title: Document.forms +slug: Web/API/Document/forms +tags: + - API + - DOM + - Document + - Forms + - HTML DOM + - HTML forms + - Proprietà + - Referenza +translation_of: Web/API/Document/forms +--- +<p><span class="seoSummary">La proprietà di sola lettura <strong><code>forms</code></strong> dell'interfaccia {{domxref("Document")}} restituisce una {{domxref("HTMLCollection")}} che elenca tutti gli elementi {{HTMLElement("form")}} contenuti nel documento.</span></p> + +<div class="note"> +<p><strong>Note:</strong> Allo stesso modo, è possibile accedere a un elenco di elementi di input utente di un modulo utilizzando la proprietà {{domxref("HTMLFormElement.elements")}}.</p> +</div> + +<h2 id="Syntax" name="Syntax">Sintassi</h2> + +<pre class="syntaxbox"><var>collection</var> = <em>document</em>.forms;</pre> + +<h3 id="Valore">Valore</h3> + +<p>Un oggetto {{domxref("HTMLCollection")}} che elenca tutti i form del documento. Ogni elemento della collezione è un {{domxref("HTMLFormElement")}} che rappresenta un singolo elemento <code><form></code>.</p> + +<p>Se il documento non ha moduli, la raccolta restituita è vuota, con una lunghezza pari a zero.</p> + +<h2 id="Example" name="Example">Esempi</h2> + +<h3 id="Ottenere_informazioni_sul_modulo">Ottenere informazioni sul modulo</h3> + +<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> + +<h3 id="Ottenere_un_elemento_all'interno_di_un_modulo">Ottenere un elemento all'interno di un modulo</h3> + +<pre class="brush: js">var selectForm = document.forms[index]; +var selectFormElement = document.forms[index].elements[index]; +</pre> + +<h3 id="Accesso_al_modulo_con_nome">Accesso al modulo con nome</h3> + +<pre class="brush: html"><!DOCTYPE html> +<html lang="en"> +<head> + <title>document.forms example</title> +</head> + +<body> + +<form name="login"> + <input name="email" type="email"> + <input name="password" type="password"> + <button type="submit">Log in</button> +</form> + +<script> + var loginForm = document.forms.login; // Or document.forms['login'] + loginForm.elements.email.placeholder = 'test@example.com'; + loginForm.elements.password.placeholder = 'password'; +</script> +</body> +</html> +</pre> + +<h2 id="Specifications" name="Specifications">Specifiche</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specifica</th> + <th scope="col">Stato</th> + <th scope="col">Commento</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>Definizione iniziale.</td> + </tr> + </tbody> +</table> + +<h2 id="See_Also" name="See_Also">Compatibilità con i browser</h2> + + + +<p>{{Compat("api.Document.forms")}}</p> + +<h2 id="See_Also" name="See_Also">Vedi anche</h2> + +<ul> + <li><a href="/en-US/docs/Learn/HTML/Forms">HTML forms</a></li> + <li>{{HTMLElement("form")}} e l'interfaccia {{domxref("HTMLFormElement")}}</li> +</ul> + +<div>{{APIRef("DOM")}}</div> |
