Js submission form solves the problem of multiple submit buttons on a page

  • 2020-03-30 03:47:32
  • OfStack

Js submit form to solve the problem of multiple submit buttons on a page, mainly to determine whether the text is submitted, and then perform the corresponding action, relatively simple.


<pre class="javascript" name="code">function check(txt){ 
$j("form").submit(function(){ 
if($txt==" submit "){ 
this.action="doAddMessage.action?button= submit "; 
this.submit(); 
}else{ 
this.action="doAddMessage.action?button= save "; 
this.submit(); 
} 
}); 
}</pre><br> 
<input type="IMAGE" src="style/blue/images/button/send.png" name="button" value=" submit " onclick="check(this)"/><input type="IMAGE"src="style/blue/images/button/saveToDraftBox.png" name="button" value=" save " onclick="check(this)"/> 
<pre></pre> 
<p><br> 
 For example, : There are two picture button submissions in the page, we can bind them all at this time onclick Event, this time we use the jquery the form The form has an event called submit . </p> 
<p> As shown in the picture, because I used it in my project dwr, I put the jquery The transfer of control to dwr . jquery To specify   a $j, We get the form and we use it submit Events, by judgment value , so that multiple pages can be skipped. </p> 
<p> </p> 
<p> </p> 

Related articles: