form name Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:form

Description

The name attribute sets the name of a form which is used to reference elements in a JavaScript, or to reference form data after a form is submitted.

Attribute Values

Value Description
text Specifies the name of the form

An HTML form with a name attribute:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script>
function formSubmit() {<!-- ww w .  j a v  a2 s .co  m-->
    document.forms["myForm"].submit();
}
</script>
</head>
<body>

<form name="myForm" action="/action_page.php" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br><br>
<input type="button" onclick="formSubmit()" value="Send form data!">
</form>

</body>
</html>

Related Tutorials