다른 양식에 정의 된 단추를 통해 양식을 제출할 때 문제점이 있습니다.복수 양식 상호 작용
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test submit</title>
</head>
<body>
<form id="dummyForm" name="dummyForm">
<button onclick="sendTheForm();">Submit other form</button>
</form>
<form id="formID" name="formName" action="viewpost.php" method="POST">
<input type="hidden" value="something" id="inputA1" name="inputA1" />
<input type="hidden" value="something" id="inputA2" name="inputA2" />
</form>
<script type="text/javascript">
function sendTheForm() {
document.forms['formName'].submit();
}
</script>
</body>
</html>
다음 줄을 변화 예상대로 리디렉션 달성 할 수있는 유일한 방법 :
onclick="sendTheForm();return false;"
내가 양식 제출 이런 식으로 작동하는지 이해하지 않습니다. 아무도 설명 할 수 있을까요?
감사합니다.
특정 버튼은 제출 유형이 아니므로 더미 양식이 트리거를 처음 제출하는 이유는 알 수 없습니다. ** 버튼의 기본 동작은 무엇입니까? ** 답변 : [버튼 참조] (http://w3c.github.io/html-reference/button.html) – nhereveri
@nhereveri - ** ** 제출 유형. 당신이 지적한 링크는 다음과 같습니다 : * 유형 속성이 지정되지 않은 버튼 요소는 type 속성이 "submit"로 설정된 버튼 요소와 동일한 것을 나타냅니다 * – Quentin
예. 2 단계에서 몇 분 후에 체크 했어요. – nhereveri