zoukankan      html  css  js  c++  java
  • javascript 二级联动

    <html> 
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">

    <style>
    body,select
    {
    font-size:9pt;
    font-family:Verdana;
    }
    a
    {
    color:red;
    text-decoration:none;
    }
    a:hover{
    text-decoration:underline;
    }
    </style>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function Dsy()
    {
    this.Items = {};
    }
    Dsy.prototype.add = function(id,iArray)
    {
    this.Items[id] = iArray;
    }
    Dsy.prototype.Exists = function(id)
    {
    if(typeof(this.Items[id]) == "undefined") return false;
    return true;
    }

    function change(v){
    var str="0";
    for(i=0;i<v;i++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));};
    var ss=document.getElementById(s[v]);
    with(ss){
    length = 0;
    options[0]=new Option(opt0[v],opt0[v]);
    if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v)
    {
    if(dsy.Exists(str)){
    ar = dsy.Items[str];
    for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
    if(v)options[1].selected = true;
    }
    }
    if(++v<s.length){change(v);}
    }
    }

    var dsy = new Dsy();

    dsy.add("0",["1","2","3","4"]);

    dsy.add("0_0",["11","12","13"]);
    dsy.add("0_1",["21","22","23"]);
    dsy.add("0_2",["31","32","33"]);
    dsy.add("0_3",["41","42","43"]);

    //-->
    </SCRIPT>
    <SCRIPT LANGUAGE = JavaScript>

    var s=["s1","s2"];
    var opt0 = ["请选择","请选择"];
    function setup()
    {
    for(i=0;i<s.length-1;i++)
    document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
    change(0);
    }
    //-->
    </SCRIPT>
    </head>
    <body bgcolor="#E0E0E0" onload="setup()">

    <form name="frm" action="11.jsp">
    <select id="s1" name="s1"><option></option></select>
    <select id="s2" name="s2"><option></option></select>
    <input type="submit" name="Submit" value="提交">
    </form>
    </body>
    </html>

    ------
    11.jsp

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    String s1 = request.getParameter("s1");
    String s2 = request.getParameter("s2");
    out.println(s1);
    out.println(s2);

    %>
    </body>
    </html>

    --------------------------



    yinyong:http://zhidao.baidu.com/question/74257440.html
  • 相关阅读:
    COGS——T2084. Asm.Def的基本算法
    COGS——T1310. [HAOI2006]聪明的猴子
    python(4)- 简单练习:python实现购物车的优化
    Windows CE,你妈吗喊你在多核上玩玩
    xp宿主机和VMware下Ubuntu12.04共享文件夹
    xp主机用VMware9和10安装Ubuntu12.04后无法进入图像界面
    Ubuntu12.04 VMware Tools的安装
    linux 目录结构
    vmware-tools安装指南
    抱怨IT公司人才缺乏?留住现有人才方是正途
  • 原文地址:https://www.cnblogs.com/meimao5211/p/3209604.html
Copyright © 2011-2022 走看看