Home > Web Front-end > JS Tutorial > Use js to submit a form to solve the problem of multiple submit buttons on a page_javascript skills

Use js to submit a form to solve the problem of multiple submit buttons on a page_javascript skills

WBOY
Release: 2016-05-16 16:38:08
Original
1140 people have browsed it

Use js to submit the form to solve the problem of multiple submit buttons on a page. The main thing is to determine whether it is a submitted text, and then perform the corresponding action. It is relatively simple.

<pre class="javascript" name="code">function check(txt){ 
$j("form").submit(function(){ 
if($txt=="提交"){ 
this.action="doAddMessage.action&#63;button=提交"; 
this.submit(); 
}else{ 
this.action="doAddMessage.action&#63;button=保存"; 
this.submit(); 
} 
}); 
}

 


例如:页面中有两个图片按钮的提交,我们这个时候可以给他们都绑定onclick事件,这个时候我们借助jquery的form表单有个事件,叫做submit的。

如图,由于,我的项目里面用了dwr,我把jquery的控制权转让给dwr,jquery重新指定 了一个$j,我们获取表单,然后使用submit事件,通过判断value的值,从而可以进行多个页面的跳转。

Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template