HTMLFormElement
Formularz 1
<form action="HTMLFormElement.htm" id="form1" name="formularz1">
<input type="text" id="imie" name="name" value="Imię">
<button type="submit" id="przycisk1" name="button">Wyślij formularz</button>
</form>
Formularz 2
<form action="HTMLFormElement.htm" id="form2" name="formularz2">
<input type="text" id="nazwisko" name="surname" value="Nazwisko">
<input type="submit" id="przycisk2" name="button" value="Wyślij formularz">
</form>
Kolekcja fomularzy
<script>
document.write("<pre>");
document.write("document.forms = " + document.forms + "\n"); // kolekcja formularzy
document.write("document.forms.length = " + document.forms.length);
document.write("</pre>");
</script>
Dostęp tablicowy 1
<script>
document.write("<pre>");
document.write("document.forms[0] = " + document.forms[0] + "\n");
document.write("document.forms[1] = " + document.forms[1] + "\n");
document.write("document.forms[2] = " + document.forms[2]);
document.write("</pre>");
</script>
Dostęp tablicowy 2
<script>
document.write("<pre>");
document.write("document.forms['form1'] = " + document.forms['form1'] + "\n"); // wartość atrybutu id
document.write("document.forms['form2'] = " + document.forms['form2'] + "\n");
document.write("document.forms['form3'] = " + document.forms['form3']);
document.write("</pre>");
</script>
Dostęp tablicowy 3
<script>
document.write("<pre>");
document.write("document.forms['formularz1'] = " + document.forms['formularz1'] + "\n"); // wartość atrybutu name
document.write("document.forms['formularz2'] = " + document.forms['formularz2'] + "\n");
document.write("document.forms['formularz3'] = " + document.forms['formularz3']);
document.write("</pre>");
</script>
Dostęp przez klucz 1
<script>
document.write("<pre>");
document.write("document.forms.form1 = " + document.forms.form1 + "\n");
document.write("document.forms.form2 = " + document.forms.form2 + "\n");
document.write("document.forms.form3 = " + document.forms.form3);
document.write("</pre>");
</script>
Dostęp przez klucz 2
<script>
document.write("<pre>");
document.write("document.forms.formularz1 = " + document.forms.formularz1 + "\n");
document.write("document.forms.formularz2 = " + document.forms.formularz2 + "\n");
document.write("document.forms.formularz3 = " + document.forms.formularz3);
document.write("</pre>");
</script>
Komponenty formularza
<script>
document.write("<pre>");
document.write("document.forms[0].elements = " + document.forms[0].elements + "\n"); // kolekcja komponentów formularza
document.write("document.forms[0].elements.length = " + document.forms[0].elements.length + "\n\n");
document.write("document.forms[1].elements = " + document.forms[1].elements + "\n");
document.write("document.forms[1].elements.length = " + document.forms[1].elements.length);
document.write("</pre>");
</script>
Dostęp do komponentów formularza 1
<script>
document.write("<pre>");
document.write("document.forms[0].elements[0] = " + document.forms[0].elements[0] + "\n");
document.write("document.forms[0].elements[1] = " + document.forms[0].elements[1]);
document.write("</pre>");
</script>
<script>
document.write("<pre>");
document.write("document.forms[0][0] = " + document.forms[0][0] + "\n");
document.write("document.forms[0][1] = " + document.forms[0][1]);
document.write("</pre>");
</script>
Dostęp do komponentów formularza 2
<script>
document.write("<pre>");
document.write("document.forms[0].elements['imie'] = " + document.forms[0].elements['imie'] + "\n");
document.write("document.forms[0].elements['przycisk1'] = " + document.forms[0].elements['przycisk1']);
document.write("</pre>");
</script>
<script>
document.write("<pre>");
document.write("document.forms[0]['imie'] = " + document.forms[0]['imie'] + "\n");
document.write("document.forms[0]['przycisk1'] = " + document.forms[0]['przycisk1']);
document.write("</pre>");
</script>
Dostęp do komponentów formularza 3
<script>
document.write("<pre>");
document.write("document.forms[0].elements['name'] = " + document.forms[0].elements['name'] + "\n");
document.write("document.forms[0].elements['button'] = " + document.forms[0].elements['button']);
document.write("</pre>");
</script>
<script>
document.write("<pre>");
document.write("document.forms[0]['name'] = " + document.forms[0]['name'] + "\n");
document.write("document.forms[0]['button'] = " + document.forms[0]['button']);
document.write("</pre>");
</script>