Home  >  Article  >  Web Front-end  >  js implementation of form multi-button submission action processing method_javascript skills

js implementation of form multi-button submission action processing method_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:35:261286browse

The previous article introduced how to implement multi-button form submission action in PHP. Today I will introduce a js method to implement multi-button form submission action. I hope it can help everyone.

Use JS to implement multiple buttons on a form, handle two onclick events, the code is as follows:

<html>  
<head>  
<script>  
  function submitit1()  
  //交由程序1处理    
  {  
    document.myForm.action = "http://www.site.com/cgi1.php"  
    document.myForm.submit();  
  }  
  function submitit2()  
  //交由程序2处理    
  {  
    document.myForm.action = "http://www.site.com/cgi2.php"  
    document.myForm.submit();  
  }  
</script>  
</head>  
  
<body>  
<form name="myForm" METHOD=POST>  
  username:<input type=text name=text1>  
  password:<input type=password name=text2>  
  <input type=button value="Submit1" onClick=submitit1();>  
  <input type=button value="Submit2" onClick=submitit2();>  
</form>  
</body>  
</html> 

You can study together with the previous article "How to implement multi-button submission action in a form in PHP ", and the effect may be better.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn