一个form有两个提交按钮的问题。
function searchReslut(){
<%
String str社員ID = "0001 ";
String str作業日 = request.getParameter( "txtSagyobi ");
System.out.println(str作業日);
ArrayList array=new ArrayList();
ShuhoInputHelper shuhoInputHelper=new ShuhoInputHelper();
array=shuhoInputHelper.getAllUser(str社員ID, str作業日);
Iterator i=array.iterator();
int j = 1;
while(i.hasNext())
{
ShuhoInputModel shuhoInputModel=(ShuhoInputModel)i.next();
%>
document.forms[0].item( "txtAnken " + " <%=j%> ").value = " <%=shuhoInputModel.getStr案件()%> ";
document.forms[0].item( "txtIraiBuka " + " <%=j%> ").value = " <%=shuhoInputModel.getStr依頼部課()%> ";
document.forms[0].item( "txtSagyoNaiyo " + " <%=j%> ").value = " <%=shuhoInputModel.getStr作業内容()%> ";
<%
j++;
}
%>
}
function dataInsert()
{
<%
shuhoInputHelper=new ShuhoInputHelper();
try
{
for (int m = 1; m <= 10; m++)
{
String str案件=request.getParameter( "txtAnken " + m);
str案件 = new String(str案件.getBytes( "ISO8859_1 "), "MS932 ");
if (str案件 != null && !str案件.equals( " "))
{
String str依頼部課=request.getParameter( "txtIraiBuka " + m);
str依頼部課 = new String(str依頼部課.getBytes( "ISO8859_1 "), "MS932 ");
String str作業内容=request.getParameter( "txtSagyoNaiyo " + m);
str作業内容 = new String(str作業内容.getBytes( "ISO8859_1 "), "MS932 ");
shuhoInputHelper.setStr社員ID( "0001 ");
shuhoInputHelper.setStr作業日(request.getParameter( "txtSagyobi "));
shuhoInputHelper.setStr項番(String.valueOf(m));
shuhoInputHelper.setstr案件(str案件);
shuhoInputHelper.setstr依頼部課(str依頼部課);
shuhoInputHelper.setstr作業内容(str作業内容);
shuhoInputHelper.addData();
}
}
}
catch(Exception e)
{
}
%>
}
<input type= "button " style= "width: 50; height: 50; border: 0; bgcolor=#ffffff " name = "btnHozon " value= "保存 "
onclick= "form1.submit();dataInsert() ">
<input type= "button " style= "width: 50; height: 50; border: 0; bgcolor=#ffffff " name = "btnSearch " value= "検索 "
onClick= "form1.submit();searchReslut() ">
代码如上所示,现在的问题是我点击检索button的时候,也会把dataInsert方法里面的 <%...%> 这部分代码也执行了,点击保存的时候同样也把searchReslut方法里面的 <%...%> 这部分也执行了。不知道怎样可以在点击检索button的时候,屏蔽掉dataInsert方法里面的 <%...%> 这部分代码。点击保存的时候同样,希望哪位大侠能帮帮忙看看。谢谢了。在线等!!!!
------解决方案--------------------本人对JS不熟悉,不知道这样写对不对,
但思路是正确的,供你参考吧,呵呵