<form name="form1" method="post" action="htps_submit_contrl.jsp">
......
<input type="image" border="0" name="submit_type01" value="01" src="dzsw/image/ps_submit01.bmp">
<input type="image" border="0" name="submit_type02" value="02" src="dzsw/image/ps_submit02.bmp">
.......
String submit_type = request.getParameter("submit_type01");
System.out.println(submit_type);
......
<input type="image" border="0" name="submit_type01" value="01" src="dzsw/image/ps_submit01.bmp">
<input type="image" border="0" name="submit_type02" value="02" src="dzsw/image/ps_submit02.bmp">
.......
String submit_type = request.getParameter("submit_type01");
System.out.println(submit_type);
在form页放一个hidden框sub;
上面的部分代码作如下修改。
<input type="image" border="0" name="submit_type" onclick="form1.sub.value='01';" src="dzsw/image/ps_submit01.bmp">
<input type="image" border="0" name="submit_type" onclick="form1.sub.value='02';" src="dzsw/image/ps_submit02.bmp">
<input type="image" border="0" name="submit_type" onclick="form1.submit_type.value='01';document.form1.submit();" src="dzsw/image/ps_submit01.bmp">
<input type="image" border="0" name="submit_type" onclick="form1.submit_type.value='02';document.form1.submit()" src="dzsw/image/ps_submit02.bmp">
<input type=hidden name=submit_type>
</form>
String submit_type = request.getParameter("submit_type");
正如楼上说的,最好还要弄点hidden.
其实可以用JavaScript 动态改变action 值。
我不明白你为什么要获得submit 值,我 猜测是你想根据不同值做出不同的处理吧。
说明白还有更好的方法实现的。
说得对!
但是,action是提交不同的jsp页面处理吧,那样就太麻烦了。我想在页面上有不同的提交按钮,后台在同一个jsp里面得到这个submit的不同分类,而把提交过来的form表单变量以不同的方式处理!我现在举例:
jsp1.jsp里面有关评审合同内容,如果你是普通评审员,要通过此合同的评审,有几种方式,其一,在权限内直接提交通过,其二,提交部长评审,其三,提交经理评审。因此页面上必有此三种submit(我想用Image)。
jsp2.jsp可以判断此提交类型,而对数据库作出相应处理!
String login=request.getParameter("login.x");
String register=request.getParameter("register.x");
String lose=request.getParameter("lose.x");
%><%
if(login!=null){ //~ ......
}//~else if(register!=null){
response.sendRedirect("login.jsp");
}
else if(lose!=null){
response.sendRedirect("lose.jsp");
}%>我这里用了三个image提交(注册/登录/忘记密码,很实用啊:),
我只留下了搂主需要的部分,应该很清晰了吧~