본문 바로가기

HTML

(HTML) 폼 액션(form action) 변경 예제

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

이건 한 개의 폼에 두 개를 실행이 가능한 예제이다.


신기하다.


출처 : http://msoup.tistory.com/entry/Java-script-form-action-%EB%B3%80%EA%B2%BD%EC%98%88%EC%A0%9C


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<html>
<script language=javascript>
function getPost(mode)
{
var theForm = document.frmSubmit;
if(mode == "01")
{
theForm.method = "post"
theForm.target = "_self";
 theForm.action = "test01.asp";
}
else if(mode == "02")
{
     theForm.method = "get";
     theForm.target = "_blank";
     theForm.action = "test02.asp"
}
theForm.submit();
}
</script>
<body>
<form name=frmSubmit>
<input type=text name=txt1><br>
<input type=text name=txt2><br>
<input type=button name=btn1 value="Submit01" onClick="getPost('01')">
<input type=button name=btn2 value="Submit02" onClick="getPost('02')">
</form>
</body>
</html>
cs