HTML DOM Form submit() 메소드는 action 속성에 의해 지정된 주소로 양식 데이터를 제출하는 데 사용됩니다. 양식 데이터를 제출하는 제출 버튼 역할을 하며 어떤 종류의 매개변수도 사용하지 않습니다.
구문
다음은 Form submit() 메소드의 구문입니다 -
formObject.submit()
예시
Form submit() 메서드의 예를 살펴보겠습니다.
<!DOCTYPE html>
<html>
<head>
<style>
form{
border:2px solid blue;
margin:2px;
padding:4px;
}
</style>
<script>
function ResetForm() {
document.getElementById("FORM1").reset();
document.getElementById("Sample").innerHTML="Form has been reset";
}
</script>
</head>
<body>
<h1>Form reset() method example</h1>
<form id="FORM1" method="post" action="/sample_page.php">
<label>User Name <input type="text" name="usrN"></label> <br><br>
<label>Age <input type="text" name="Age"><label> <br><br>
<input type="submit" value="SUBMIT">
<input type="button" onclick="ResetForm()" value="RESET">
</form>
<p id="Sample"></p>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

SUBMIT 버튼을 클릭하면 양식이 제출되고 "sample_page.php"에 다음이 표시됩니다 -

위의 예에서 -
먼저 id=”FORM1”, method=”post” 및 action=”/sample_page.php”를 사용하여 양식을 만들었습니다. 텍스트 유형이 있는 두 개의 입력 필드와 SUBMIT −
라는 버튼이 포함되어 있습니다.<form id="FORM1" method="post" action="/sample_page.php"> <label>User Name <input type="text" name="usrN"></label> <br><br> <label>Age <input type="text" name="Age"><label> <br><br> <input type="submit" value="SUBMIT"> <input type="button" onclick="ResetForm()" value="RESET"> </form>
SUBMIT 버튼은 사용자가 클릭했을 때 SubmitForm() 메소드를 실행합니다 -
<input type="button" onclick="SubmitForm()" value="SUBMIT">
ResetForm() 메서드는 문서 객체 getElementById() 메서드를 사용하여