运行 ❯
获取您的
自己
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 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>