用js提交表單解決一個(gè)頁(yè)面有多個(gè)提交按鈕的問(wèn)題,主要是判斷是否為提交文本,然后再執(zhí)行相應(yīng)的動(dòng)作,比較簡(jiǎn)單。
<pre class="javascript" name="code">function check(txt){ $j("form").submit(function(){ if($txt=="提交"){ this.action="doAddMessage.action?button=提交"; this.submit(); }else{ this.action="doAddMessage.action?button=保存"; this.submit(); } }); }</pre><br> <input type="IMAGE" src="style/blue/images/button/send.png" name="button" value="提交" onclick="check(this)"/><input type="IMAGE"src="style/blue/images/button/saveToDraftBox.png" name="button" value="保存" onclick="check(this)"/> <pre></pre> <p><br> 例如:頁(yè)面中有兩個(gè)圖片按鈕的提交,我們這個(gè)時(shí)候可以給他們都綁定onclick事件,這個(gè)時(shí)候我們借助jquery的form表單有個(gè)事件,叫做submit的。</p> <p>如圖,由于,我的項(xiàng)目里面用了dwr,我把jquery的控制權(quán)轉(zhuǎn)讓給dwr,jquery重新指定 了一個(gè)$j,我們獲取表單,然后使用submit事件,通過(guò)判斷value的值,從而可以進(jìn)行多個(gè)頁(yè)面的跳轉(zhuǎn)。</p> <p> </p> <p> </p>
新聞熱點(diǎn)
疑難解答
圖片精選