两种形式的两个按钮碰到两个servlet [英] Two buttons in a single form hitting two servlets
本文介绍了两种形式的两个按钮碰到两个servlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想知道是否可以在一个表单中有两个按钮,这会碰到两个不同的servlet.
我已经用谷歌搜索过,一些解决方案说可以通过在javascript函数中提供form_name.action来实现.我尝试这样做,但成功了.
Hi All,
I want to know whether is it possible to have two buttons in a single form, which hits two different servlets.
I have googled about it and some of the solution says is it possible by giving form_name.action in a javascript function. I tried doing this but dint succeed.
function doSumthing(){
document.formName.action=''servletPath'';
}
另外,如果有人可以告诉我servlet路径是什么.
如果有人可以在同一方面帮助我.
预先感谢,
Kejal
Also if somebody could tell me what is the servlet path.
If somebody could help me on the same.
Thanks in advance,
Kejal
推荐答案
尝试一下:
Try this:
<HTML>
<HEAD>
<TITLE>Using Buttons</TITLE>
</HEAD>
<BODY>
<H1>Using Buttons</H1>
<FORM NAME="form1" ACTION="default.jsp" METHOD="POST">
<INPUT TYPE="HIDDEN" NAME="buttonName">
<INPUT TYPE="BUTTON" VALUE="Button 1" ONCLICK="button1()">
<INPUT TYPE="BUTTON" VALUE="Button 2" ONCLICK="button2()">
</FORM>
<SCRIPT LANGUAGE="JavaScript">
<!--
function button1()
{
document.form1.ACTION = "option1.jsp"
form1.submit()
}
function button2()
{
document.form1.ACTION = "option2.jsp"
form1.submit()
}
// -->
</SCRIPT>
</BODY>
</HTML>
这篇关于两种形式的两个按钮碰到两个servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文