一个表单,多个按钮,提交给不同的servlet处理
根据这篇文章:http://hi.baidu.com/xdsh99/blog/item/a0f4e85a184a069e810a18e9.html
方案一:
<html><head><script language=Javascript> function go(url) { formname.action=url; formname.submit();}</head><body><form method= "post " name= "formname " action= " "><input type= "button " name= "goA " value= "goA " onClick= "javascript:go( 'A.jsp ') "> <br><input type= "button " name= "goB " value= "goB " onClick= "javascript:go( 'B.jsp ') "> <br><input type= "button " name= "goC " value= "goC " onClick= "javascript:go( 'C.jsp ') "></form></body></html>
?
方案二:
<input type="button" value="提交" onclick="myForm.action='add.do';myForm.submit()"> <input type="button" value="预览" onclick="myForm.action='view.do';myForm.submit()"> <input type="button" value="更新" onclick="myForm.action='update.do';myForm.submit()">
?
其中myForm指表单的名字,这个表单有三个按钮,分别是提交,预览,更新,这三个按钮分别提交到不同的action中.
归纳出一个表单,多个按钮,提交给不同的servlet处理的代码
<form name="QuerryUserFrom" method="post"><input name="Querry" type="button" id="Querry" value=" 查 询 "><input name="delete" type="button" id="delete" onClick="QuerryUserFrom.action='DeleteServlet';QuerryUserFrom.submit()" value=" 删 除 " class="Common"></form>
?
可以在提交的servlet中写一些测试语句,验证一下。