English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Referenzhandbuch

Vollständiges Verzeichnis der HTML-Tags

HTML: <form> name Attribut

Das name-Attribut bestimmt den Namen des Formulars. Das name-Attribut wird verwendet, um Elemente in JavaScript zu referenzieren oder die Daten des Formulars nach dem Absenden des Formulars zu referenzieren.

 HTML <form> Tag

Online-Beispiel

HTML-Formulare mit dem name-Attribut:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <form> name Attribut verwenden-Grundlagen-Tutorial(oldtoolbag.com)</title>
<script>
function formSubmit() {
    document.forms["myForm"].submit();
}
</script>
</head>
<body>
<form name="myForm" action="action_page.php" method="get">
Vorname: <input type="text" name="fname"><br>
Nachname: <input type="text" name="lname"><br><br>
<input type="button" onclick="formSubmit()" value="Send form data!">
</form>
<p>Notice that the JavaScript in the header uses the form's name to specify the form to be submitted.</p>
</body>
</html>
Test to see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

All major browsers support the name attribute.

Definition and usage

The name attribute specifies the name of the form.
The name attribute is used to reference elements in JavaScript, or to reference form data after submitting the form.

HTML 4.01 with HTML5Differences

None.

Differences between HTML and XHTML

In XHTML, the name attribute is deprecated. Please use the id attribute instead.

Syntax

<form name="text">

Attribute value

ValueDescription
textSpecifies the name of the form.
 HTML <form> Tag