日期:2014-05-16  浏览次数:20427 次

关于动态三级联动的问题
我做的个页面包含三级联动,我看了大多数的实现都是建好几个表实现的,我想可不可以在一个表里实现三级联动   ,比如把三种类型全放在1个表里
下面是个例子,哪位高手帮忙改一改或有更好的方法.
总共三级,通过学院department选择系division,通过系选择专业speciality

<%@   page   language= "java "   import= "java.util.*,java.lang.*,java.sql.* "   pageEncoding= "GB18030 "%>
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">
<html>
  <head>
  <script   language= "javascript ">
    var   DeparmentCount;   //三级联动菜单代码
    DeparmentCount   =   0;
    var   DivisionCount;
    DivisionCount   =   0;
    var   SpecialityCount;
    SpecialityCount   =   0
    Department   =   new   Array();
    Division   =   new   Array();
    Speciality   =   new   Array();
<%
    system.pub.oraclesql   myDao   =   new   system.pub.oraclesql();
    ResultSet   rs   =   myDao.execQuery( "select   *   from   division ");
    int   i=0;
    for(rs.next();!rs.isAfterLast();rs.next(),i++){%>
      Division[ <%=i%> ]   =   new   Array( " <%=rs.getString( "Division_name ")%> ", " <%=rs.getString( "department_id ")%> ", " <%=rs.getString( "id ")%> ");
<%     }%>
    DivisionCount   =   <%=i%> ;

<%
    System.out.println( "debug....1 ");
    rs   =   myDao.execQuery( "select   *   from   speciality ");
    i=0;
    for(rs.next();!rs.isAfterLast();rs.next(),i++){%>
      Speciality[ <%=i%> ]   =   new   Array( " <%=rs.getString( "Speciality_name ")%> ", " <%=rs.getString( "division_id ")%> ", " <%=rs.getString( "id ")%> ");
<%     }%>
    SpecialityCount   =   <%=i%> ;
     
function   changeDepartment(DepartmentId){
  document.form1.Switch.value= "false ";
  document.form1.division.length   =   0;
          var   DepartmentId   =   DepartmentId;
          var   i;
          for   (i=0;i   <   DivisionCount;   i++){
                  if   (Division[i][1]   ==   DepartmentId){  
              document.form1.division.options[document.form1.division.length]   =   new   Option(Division[i][0],   Division[i][2]);
                          }                
                }
              changeDivision(document.form1.division.value);
}

function   changeDivision(DivisionId){
  document.form1.Switch.value= "false ";