개발자의 끄적끄적

[javascript] form action 변경예제 본문

개발/javascript & jquery

[javascript] form action 변경예제

효벨 2020. 2. 12. 01:00
728x90
반응형

[javascript] form action 변경예제

 

<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>
반응형
Comments