dwr验证框架多级联下拉菜单

时间:2011-10-10 02:06:05
【文件属性】:

文件名称:dwr验证框架多级联下拉菜单

文件大小:11KB

文件格式:TXT

更新时间:2011-10-10 02:06:05

dwr验证框架多级联下拉菜单

index.jsp(级联的重点) <%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage=""%> <% ResultSet rs_city = null; ResultSet rs_Town = null; ResultSet rs_province = null; String sql = ""; String sql_T = ""; int SelectID_C = 0; int SelectID_P=0; String strCityID1=request.getParameter("CityID"); String strSelectID_P=request.getParameter("ProvinceID"); if (strSelectID_P!=null &&!strSelectID_P.equals("")) { session.setAttribute("SelectID_P", strSelectID_P); } String sql_P = "SELECT * FROM tb_Area WHERE TypeID=1 or TypeID=4 or TypeID=5"; try { rs_province = connDB.executeQuery(sql_P); if (rs_province.next()) { if(session.getAttribute("SelectID_P")!=null){ SelectID_P= Integer.parseInt((String)session.getAttribute("SelectID_P")); }else{ SelectID_P=rs_province.getInt("ID"); } %> 级联菜单

   
 
省级名称:
<% sql = "select* from tb_area where TypeID=2 and father=" + SelectID_P + ""; sql_T = "select* from tb_area where TypeID=3 and father=" + SelectID_P + ""; rs_city = connDB.executeQuery(sql); rs_Town = connDB.executeQuery(sql_T); %>
 
市/县名称:
  <%if (rs_city.next()) { if (strCityID1==null) { SelectID_C=rs_city.getInt("ID"); }else{ SelectID_C = Integer.parseInt(request.getParameter("CityID")); } %>
<%} else { %> <% } %>
区/镇/乡名称:
<% if (SelectID_C != 0) { //选择了市县级名称 sql_T = "select* from tb_area where father=" + SelectID_C + ""; System.out.println("sql_T!=0:"+sql_T); rs_Town = connDB.executeQuery(sql_T); } %> <%if (rs_Town.next()) {%>
 
<%} else { %>
 
<%} %>
 
   
<% } } catch (Exception e) { System.out.println("查询省级名称时出错:"+e.getMessage()); } %> style.css


网友评论