有关提交表单的问题.如果用不用BUTTON提交, 而用SUBMIT提交则正确提交.

nyliuhaiyang 2003-10-10 09:12:05
<html>
<head>
<%@ page contentType="text/html;charset=Big5" %>
<%@ page import="java.sql.*"%>
<jsp:useBean id="db" scope="page" class="hello.condb" />
<jsp:useBean id="db1" scope="page" class="hello.catapage" />

<title>出車明細資料查詢</title>
</head>
<script>
function sub(){
document.forms[0].act.value="query";
document.forms[0].action="";
document.forms[0].submit();
return true;
}
</script>

<form method="post" action="cc.jsp" name="form1">
<table border="0" width="100%">
<tr>
<td width="20%">出車日期</td>
<td width="20%"><input type="text" name="dt" size="20"></td>
</tr>
<tr>

<td width="20%">收貨人</td>
<td width="20%"><input type="text" name="receive" size="20"></td>
</tr>

<tr>
<td width="100%" colspan="5">
<p align="center">
<input type="button" name="submit" value=" 查詢 " onclick="sub();">

<input type="hidden" name="act">

</td>
</tr>
</table>
<p align="center"> </p>

<% String receive4=request.getParameter("receive");
String sql3=null;
String btn=request.getParameter("act");
if (btn==null) btn="";
if ("query".equals(btn))
{
session.putValue("cc_l.sql",sql3);
}
String sq=null;
sq=(String)session.getValue("cc_l.sql");
if (sq==null) sq="";

String sql1="select count(*)";
sql1+=" from carry_m,carry_l where carry_m.dt=carry_l.dt and carry_m.lic_hk=carry_l.lic_hk";
sql1=sql1+sq;
ResultSet rs1=db.executeQuery(sql1);
rs1.next();
int rowCount=rs1.getInt(1); //查詢出符合條件的總行數.
out.print(rowCount);
%>
</form>
</body>
</html>
请指教.这是一个用到HIDDEN类型的问题.怎么样改正???
...全文
65 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
aku0708 2003-10-10
  • 打赏
  • 举报
回复
up
nyliuhaiyang 2003-10-10
  • 打赏
  • 举报
回复

<input type="button" name="submit" value=" 查詢 " onclick="sub();">
就是name出错了.取名可能不对..
现在好了!谢了!!
pxboy 2003-10-10
  • 打赏
  • 举报
回复
name="submit"
这里也改一下,
name="submit1"
Ukyome 2003-10-10
  • 打赏
  • 举报
回复
他们该说的都说了。
pxboy 2003-10-10
  • 打赏
  • 举报
回复
还不行你把return true;去掉
pxboy 2003-10-10
  • 打赏
  • 举报
回复
难道你没看到你是先:
document.forms[0].action="";

document.forms[0].submit();
还有怎么说?
nyliuhaiyang 2003-10-10
  • 打赏
  • 举报
回复
可我的<FORM>里边有关action.
同时. 我又在action里边加入了内容, 还是不行啊??
请指点??
thefishwilldie 2003-10-10
  • 打赏
  • 举报
回复
up!

document.forms[0].action="cc.jsp";
pxboy 2003-10-10
  • 打赏
  • 举报
回复
function sub(){
document.forms[0].act.value="query";
document.forms[0].action="";
document.forms[0].submit();
return true;
}

按button时action都成了"",还提交到哪去呀?

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧