高分求教!按回车提交的问题? 你有没有转向啊??提交了不转到新的页面text就清空阿 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head><title></title><script language=javascript>function handin(){ if(window.event.keyCode==13) { form1.submit(); }} </script></head><body topmargin="0" leftmargin="0" onkeypress="handin()"><form name="form1" action="test.jsp" method="post">uid:<input type="text" name="uid"><br>pwd:<input type="password" name="pwd"><br><input type="button" value="submit" onclick="form1.submit()"></form></body></html> 我是让他提交到自身这个页面,所以action="";但是我在上面加上action="waresch.jsp"依然不行! 自己页面有接受传过来的参数嘛?收过来的参数放在text中显示了吗? 代码如下:<%common dbconn=null;dbconn=new common();ResultSet rs;String strSQL=null;String tool=null,type=null,warestatus=null,closestatus=null;String warename=null,pieces=null,weight=null,note=null;String id=request.getParameter("id").trim();int k=Integer.parseInt(id) ;//***********************提交******************if (request.getParameter("B1")!=null){//得到工具代号 tool=request.getParameter("toolno").trim();//执行查询 strSQL="select containerno,position,tightno,goods,pieces,weight from pcmx where vanno='"+tool+"'"; rs=dbconn.executeQuery(strSQL); if (rs.next()){ //箱号/箱型 type=rs.getString("containerno"); if(type==null){type="";}else{type=type.trim();} //货物状态 warestatus=rs.getString("position"); if(warestatus==null){warestatus=" ";}else{warestatus=warestatus.trim();} //施封状态 closestatus=rs.getString("tightno"); if(closestatus==null){closestatus=" ";}else{closestatus=closestatus.trim();} //货物状态 warename=rs.getString("goods"); if(warename==null){warename=" ";}else{warename=warename.trim();} //件数 pieces=rs.getString("pieces"); if(pieces==null){pieces=" "; }else{pieces=pieces.trim();} //重量 weight=rs.getString("weight"); if(weight==null){weight=" ";}else{ weight=weight.trim();} }%><SCRIPT LANGUAGE="JavaScript"><!--window.opener.document.frm.tool<%=k%>.value="<%=tool%>";window.opener.document.frm.type<%=k%>.value="<%=type%>";window.opener.document.frm.warestatus<%=k%>.value="<%=warestatus%>";window.opener.document.frm.closestatus<%=k%>.value="<%=closestatus%>";window.opener.document.frm.warename<%=k%>.value="<%=warename%>";window.opener.document.frm.pieces<%=k%>.value="<%=pieces%>";window.opener.document.frm.weight<%=k%>.value="<%=weight%>";window.close();//--></SCRIPT><% }else{%><form method="post" name="waresch" action=""><div>输入运输工具号:<INPUT TYPE="text" NAME="toolno"><center><input type="hidden" name="id" value="<%=k%>"><INPUT TYPE="submit" name="B1" value="确定" class="button" style="cursor:hand"></center></div></form><%}dbconn.close();%></body></html> 一个完整的例子<%@page contentType="Text/html;charset=Gb2312"%><html><head><title>登陆页面</title></head><script language="javascript">function user_name_onkeypress() { if(window.event.keyCode==13) f1.password.focus(); } function Password_onkeypress() { if(window.event.keyCode==13) ok_click(); } function ok_click(){ f1.submit(); }</script><body ><form name="f1" method="post" action="login.jsp" ><table align=center border=0><tr><td>操作员登陆</td></tr></table><table border=1 cellspacing=0 align=center cellpadding="0" cellspacing="0" bordercolordark="#FFFFFF" bordercolor="#4055b0" style="font-family: 宋体; font-size: 11pt"><tr><td>用户名</td><td><input type="text" name="user_name" value="" onkeypress="return user_name_onkeypress()"></td></tr><tr><td>密码</td><td><input type="password" name="password" onkeypress="return Password_onkeypress()"></td><input type="hidden" name="mode" value="0"></tr><tr><td colspan=2 align=center><input type="button" name="ok" onclick="ok_click()" value="确定"><input type="reset" name="quit" value="取消"></td></tr></table></form></body></html> action里要写你转向的地址啊如果写了后,你看看这里对吗?if (request.getParameter("B1")!=null){//得到工具代号 tool=request.getParameter("toolno").trim();是要先得到B1的值吗?错了吧? 首先我试过你FORM的提交是没有问题的,那么你说的问题就在提交以后。哈哈,解决方法如下:你可以通过判断刷新该页面的方法是“POST”或者“GET”来区别啊如果是POST,就进行参数的传递以及数据库的操作,如果是GET就只进行显示界面 还是不太懂,怎么进行POST和GET的判断呢?我是菜鸟,有代码吗? 我刚才试了下,如果多加一个文本域就可以按回车提交,但是为什么当FORM中只有一个文本域时就不行呢?? 在表单里,如果有submit按钮的话,在文本框里不需要做任何处理也能用按下回车来提交表单 修改jsp jboss重启 SQL SERVER 2005问题!急! 请教js传值问题。。。。。。。。。。。。。。。 一个jsp问题! 两个问题:一个是隐藏表单域,一个是hidden是怎样隐藏的? 谁能帮我看看这个错误啊,困扰了我已经两天了 如何用存储过程或触发器自动在某个给定时间执行数据库操作?(分不够再给) 谁知道那有侯捷译的thinking in java 2电子版的 简体中文 怎样提高树型结构的显示效率 还是关于时间的问题! 返回什么值 用户登录程序中编译错误!在线等待!!!
<head>
<title></title>
<script language=javascript>
function handin()
{
if(window.event.keyCode==13)
{
form1.submit();
}
}
</script>
</head><body topmargin="0" leftmargin="0" onkeypress="handin()">
<form name="form1" action="test.jsp" method="post">
uid:<input type="text" name="uid"><br>
pwd:<input type="password" name="pwd"><br>
<input type="button" value="submit" onclick="form1.submit()">
</form>
</body>
</html>
但是我在上面加上action="waresch.jsp"
依然不行!
收过来的参数放在text中显示了吗?
<%
common dbconn=null;
dbconn=new common();
ResultSet rs;
String strSQL=null;
String tool=null,type=null,warestatus=null,closestatus=null;
String warename=null,pieces=null,weight=null,note=null;
String id=request.getParameter("id").trim();
int k=Integer.parseInt(id) ;
//***********************提交******************
if (request.getParameter("B1")!=null){
//得到工具代号
tool=request.getParameter("toolno").trim();
//执行查询
strSQL="select containerno,position,tightno,goods,pieces,weight from pcmx where vanno='"+tool+"'";
rs=dbconn.executeQuery(strSQL);
if (rs.next()){
//箱号/箱型
type=rs.getString("containerno");
if(type==null){type="";}else{type=type.trim();}
//货物状态
warestatus=rs.getString("position");
if(warestatus==null){warestatus=" ";}else{warestatus=warestatus.trim();}
//施封状态
closestatus=rs.getString("tightno");
if(closestatus==null){closestatus=" ";}else{closestatus=closestatus.trim();}
//货物状态
warename=rs.getString("goods");
if(warename==null){warename=" ";}else{warename=warename.trim();}
//件数
pieces=rs.getString("pieces");
if(pieces==null){pieces=" "; }else{pieces=pieces.trim();}
//重量
weight=rs.getString("weight");
if(weight==null){weight=" ";}else{ weight=weight.trim();}
}
%>
<SCRIPT LANGUAGE="JavaScript">
<!--
window.opener.document.frm.tool<%=k%>.value="<%=tool%>";
window.opener.document.frm.type<%=k%>.value="<%=type%>";
window.opener.document.frm.warestatus<%=k%>.value="<%=warestatus%>";
window.opener.document.frm.closestatus<%=k%>.value="<%=closestatus%>";
window.opener.document.frm.warename<%=k%>.value="<%=warename%>";
window.opener.document.frm.pieces<%=k%>.value="<%=pieces%>";
window.opener.document.frm.weight<%=k%>.value="<%=weight%>";
window.close();
//-->
</SCRIPT>
<%
}else{
%>
<form method="post" name="waresch" action="">
<div>
输入运输工具号:
<INPUT TYPE="text" NAME="toolno">
<center>
<input type="hidden" name="id" value="<%=k%>">
<INPUT TYPE="submit" name="B1" value="确定" class="button" style="cursor:hand">
</center>
</div>
</form>
<%
}
dbconn.close();
%>
</body>
</html>
<head>
<title>
登陆页面
</title>
</head>
<script language="javascript">
function user_name_onkeypress() { if(window.event.keyCode==13) f1.password.focus(); } function Password_onkeypress() { if(window.event.keyCode==13) ok_click(); }
function ok_click(){
f1.submit();
}
</script><body >
<form name="f1" method="post" action="login.jsp" >
<table align=center border=0><tr><td>操作员登陆</td></tr></table><table border=1 cellspacing=0 align=center cellpadding="0" cellspacing="0" bordercolordark="#FFFFFF" bordercolor="#4055b0" style="font-family: 宋体; font-size: 11pt"><tr>
<td>用户名</td><td><input type="text" name="user_name" value="" onkeypress="return user_name_onkeypress()"></td>
</tr>
<tr>
<td>密码</td><td><input type="password" name="password" onkeypress="return Password_onkeypress()"></td>
<input type="hidden" name="mode" value="0">
</tr>
<tr>
<td colspan=2 align=center>
<input type="button" name="ok" onclick="ok_click()" value="确定">
<input type="reset" name="quit" value="取消">
</td>
</tr>
</table>
</form>
</body>
</html>
如果写了后,你看看这里对吗?if (request.getParameter("B1")!=null){
//得到工具代号
tool=request.getParameter("toolno").trim();是要先得到B1的值吗?错了吧?
哈哈,解决方法如下:
你可以通过判断刷新该页面的方法是“POST”或者“GET”来区别啊
如果是POST,就进行参数的传递以及数据库的操作,如果是GET就只进行显示界面
我是菜鸟,有代码吗?