📄 lookfor1.jsp
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312" import="java.sql.*"%>
<jsp:useBean id="car" class="Bean.DbConn" scope="page"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function search(){
document.form1.action="lookFor1.jsp";
document.form1.submit();
}
</script>
</head>
<body>
<form action="search.jsp" method="post" name="form1">
<%
ResultSet rs=null,rs1=null;
String str="select * from category";
car.open();
rs=car.executeQuery(str);
out.print("<select name='brand' onchange=search()>");
String brand=request.getParameter("brand");
if(rs!=null)
{
if(brand!=null)
{
while(rs.next())
{
int id=rs.getInt(1);
if(id==Integer.parseInt(brand))
{
out.print("<option value='"+id+"' selected='selected'>"+rs.getString(2)+"</option>");
}
else
{
out.print("<option value='"+id+"'>"+rs.getString(2)+"</option>");
}
}
out.print("</select>");
String st="select type from car where brand_id="+Integer.parseInt(brand);
rs1=car.executeQuery(st);
if(rs1!=null)
{
out.print("型号:<select name='type'>");
while(rs1.next())
{
out.print("<option value='"+rs1.getString(1)+"'>"+rs1.getString(1)+"</option>");
}
out.print("</select>");
}
}
else
{
while(rs.next())
{
int id=rs.getInt(1);
out.print("<option value='"+id+"' selected='selected'>"+rs.getString(2)+"</option>");
}
out.print("</select>");
out.print("型号:<select name='type'>");
out.print("<option>---请选择型号---</option>");
out.print("</select>");
}
}
%>
<input type="submit" value="GO">
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -