zoukankan      html  css  js  c++  java
  • 三级联动(有刷新)

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
        <%@ page import="java.util.*" %>
        <%@ page import="com.hanqi.dao.*" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>三级联动</title>
    
    <%
    
    String yij= request.getParameter("yij");
    
    String erj= request.getParameter("erj");
    
    int iYij = 0;
    
    if(yij != null && yij.trim().length()>0)
    {
    	iYij = Integer.parseInt(yij);
    	
    }
    int iErj = 0;
    
    if(erj != null && erj.trim().length()>0)
    {
    	iErj = Integer.parseInt(erj);
    	
    }
    
    MemberDal md = new MemberDal();
    
    //一级
    ArrayList<Members> al = md.getList(0);
    
    
    //二级
    ArrayList<Members> a2 = null;
    
    if(iYij !=0)
    {
    	a2 = md.getList(iYij);
    }
    //三级
    ArrayList<Members> a3 = null;
    if(iErj !=0)
    {
    	a3 = md.getList(iErj);
    }
    %>
    <script>
    function yijChange()
    {
    	// 传参数 刷新1级页面
    	
    	var yij = document.getElementById("yij");
    	
    	window.location.href = "List.jsp?yij="+yij.value;
    	
    	}
    	
    function erjChange()
    {
    	// 传参数 刷新2级页面
    	var yij = document.getElementById("yij");
    	var erj = document.getElementById("erj");
    	
    	window.location.href = "List.jsp?yij="+yij.value+"&erj="+erj.value;
    	
    	}
    
    </script>
    </head>
    <body>
    
    
    一级地区:
    <select id="yij" name="yij" onchange="yijChange()">
    <option value="0">未选择</option>
    <%
    
    if(al != null)
    {
    
    	for(Members u: al)
    
    	{
    //selected 状态为选中 out.print("<option value= '"+u.getID()+"' "+(u.getID()==iYij?"selected":"" ) +">"+u.getName()+""); } } %> </select> 二级地区: <select id="erj" name="erj" onchange="erjChange()"> <option value="0" selected="selected">未选择</option> <% if(a2 != null) { for(Members m: a2) { out.print("<option value= '"+m.getID()+"' "+(m.getID()==iErj?"selected":"" ) +">"+m.getName()+""); } } %> </select> 三级地区: <select id="sanj" name="sanj"> <option value="0" selected="selected">未选择</option> <% if(a3 != null) { for(Members n: a3) { out.print("<option value= '"+n.getID()+"'>"+n.getName()+""); } } %> </select> </body> </html>
  • 相关阅读:
    构建乘积数组
    数组中重复的数字
    把字符串转换成整数
    不用加减乘除做加法
    求1+2+3+...+n
    孩子们的游戏(圆圈中最后剩下的数)
    翻转单词顺序列
    扑克牌顺子
    左旋转字符串
    ES6必知必会 —— Module
  • 原文地址:https://www.cnblogs.com/chenning/p/5065171.html
Copyright © 2011-2022 走看看