프로젝트 관련 조사/웹

[Java script] form action 변경예제

호레 2016. 5. 4. 01:36
반응형

<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>

반응형