Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <script> function formSubmit() { document.forms["myForm"].submit(); } </script> </head> <body> <h1>The form name attribute</h1> <form name="myForm" action="/action_page.php" method="get"> <label for="fname">First name:</label> <input type="text" id="fname" name="fname"><br><br> <label for="lname">Last name:</label> <input type="text" id="lname" name="lname"><br><br> <input type="button" onclick="formSubmit()" value="Send form data!"> </form> <p>Notice that the JavaScript in the head section uses the name of the form to specify which form to submit.</p> </body> </html>