<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*,java.io.*" %>
<%@ page import="net.risesoft.common.database.*" %>
<html>
<head>
<title>查询</title>
<script language=javascript>
function chaxun()
{
tt1=document.form1.t1.value;
tt2=document.form1.t2.value;
cc1=document.form1.c1.checked;
cc2=document.form1.c2.checked;
if(tt1==0)
{
if(tt2==0)
{
alert("请您输入查询方式!!");
}
}
}
</script>
</head>
<body>
从数据库里查询的部门信息:<hr>
<form name=form1>
标号
<input type="text" name="t1">
<input type="checkbox" name="c1">模糊查询<br>
部门
<input type="text" name="t2">
<input type="checkbox" name="c2">模糊查询
<input type="submit" name="s1" value="查询" onclick="chaxun()">
<br>
</form>
<hr>
<table>
<tr><td>部门标号</td><td>部门名称</td></tr>
<% String tn = request.getParameter("tt1");
String tb = request.getParameter("tt2");
String c1 = request.getParameter("cc1");
String c2 = request.getParameter("cc2");
//
String sun = "";
if(tn!=null)
{
if(c1!=null)
{
sun+="and DEPARTMENT_GUID='"+tn+"'";
}
else
{
sun+="and DEPARTMENT_GUID like '%"+tn+"%'";
}
}
if(tb!=null)
{
if(c2!=null)
{
sun+="and DEPARTMENT_NAME='"+tb+"'";
}
else
{
sun+="and DEPARTMENT_NAME like '%"+tb+"%'";
}
}
Connection con=null;
con=Conn.getConnection();
ResultSet rs=null;
//
try
{
String ss="select DEPARTMENT_GUID,DEPARTMENT_NAME from RISENET_DEPARTMENT WHERE 1=1 "+sun; rs=con.createStatement().executeQuery(ss);
while(rs.next())
{ String cc=rs.getString("DEPARTMENT_GUID");
String dd=rs.getString("DEPARTMENT_NAME");
out.println("<tr>");
out.println("<td>"+cc+"</td>");
out.println("<td>"+dd+"</td>");
out.println("</tr>");
}
}
catch(Exception e)
{
out.println(e); }
finally
{
if (con!=null)
con.close();
if (rs!=null)
rs.close();
}
%>
</table>
</body>
</html>javascript的数据总是传不到JSP页面里面!
好象是
String tn = request.getParameter("tt1");
String tb = request.getParameter("tt2");
String c1 = request.getParameter("cc1");
String c2 = request.getParameter("cc2");这里不对!
谢谢大家帮忙了!!
<%@ page import="java.sql.*,java.io.*" %>
<%@ page import="net.risesoft.common.database.*" %>
<html>
<head>
<title>查询</title>
<script language=javascript>
function chaxun()
{
tt1=document.form1.t1.value;
tt2=document.form1.t2.value;
cc1=document.form1.c1.checked;
cc2=document.form1.c2.checked;
if(tt1==0)
{
if(tt2==0)
{
alert("请您输入查询方式!!");
}
}
}
</script>
</head>
<body>
从数据库里查询的部门信息:<hr>
<form name=form1>
标号
<input type="text" name="t1">
<input type="checkbox" name="c1">模糊查询<br>
部门
<input type="text" name="t2">
<input type="checkbox" name="c2">模糊查询
<input type="submit" name="s1" value="查询" onclick="chaxun()">
<br>
</form>
<hr>
<table>
<tr><td>部门标号</td><td>部门名称</td></tr>
<% String tn = request.getParameter("tt1");
String tb = request.getParameter("tt2");
String c1 = request.getParameter("cc1");
String c2 = request.getParameter("cc2");
//
String sun = "";
if(tn!=null)
{
if(c1!=null)
{
sun+="and DEPARTMENT_GUID='"+tn+"'";
}
else
{
sun+="and DEPARTMENT_GUID like '%"+tn+"%'";
}
}
if(tb!=null)
{
if(c2!=null)
{
sun+="and DEPARTMENT_NAME='"+tb+"'";
}
else
{
sun+="and DEPARTMENT_NAME like '%"+tb+"%'";
}
}
Connection con=null;
con=Conn.getConnection();
ResultSet rs=null;
//
try
{
String ss="select DEPARTMENT_GUID,DEPARTMENT_NAME from RISENET_DEPARTMENT WHERE 1=1 "+sun; rs=con.createStatement().executeQuery(ss);
while(rs.next())
{ String cc=rs.getString("DEPARTMENT_GUID");
String dd=rs.getString("DEPARTMENT_NAME");
out.println("<tr>");
out.println("<td>"+cc+"</td>");
out.println("<td>"+dd+"</td>");
out.println("</tr>");
}
}
catch(Exception e)
{
out.println(e); }
finally
{
if (con!=null)
con.close();
if (rs!=null)
rs.close();
}
%>
</table>
</body>
</html>javascript的数据总是传不到JSP页面里面!
好象是
String tn = request.getParameter("tt1");
String tb = request.getParameter("tt2");
String c1 = request.getParameter("cc1");
String c2 = request.getParameter("cc2");这里不对!
谢谢大家帮忙了!!
String tb = request.getParameter("t2");
String c1 = request.getParameter("c1");
String c2 = request.getParameter("c2");<input type="checkbox" value="0"
现在jsp里面根本就得不到前面传过来的值!!
form的action呢???
怎么犀利糊涂的
例如:
页面一:
<form name="demoFrm" action="2.jsp" method="post">
<input type="text" name="t1">
<input type="text" name="t2">
<input type="checkbox" name="c1" value="c1">
<input type="checkbox" name="c2" value="c2">
<input type="submit" name="aa" value="提交">
</form>页面二:
接收参数:
String tn = request.getParameter("t1");
String tb = request.getParameter("t2");
String c1 = request.getParameter("c1");
String c2 = request.getParameter("c2");
你为什么不将表单的数据直接提交给jsp页面呢,首先在js中检测数据是否合法,检查完成之后如果没有错误就调用表单的submit就行了啊。