• 级联列表(八大菜系)


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>级联列表</title>
        <style>
           #d{
                height:200px;
                width:200px;
               border: 1px red solid;
            }
        </style>
    </head>
    <body>
    <div id="d">
    
    </div>
    <select id="s1" onchange="b1()"></select>
    <select id="s2" onchange="b2()"></select>
    <script>
        var s1=document.getElementById("s1");
        var s2=document.getElementById("s2");
        var caixi=["鲁菜","粤菜","川菜","湘菜","闽菜","浙菜","苏菜","徽菜"];
        var caiming=[["糖醋鱼","锅烧肘子"],
                ["龙虎斗","脆皮乳猪"],
                ["樟茶鸭","宫保鸡丁"],
                ["辣合蒸","麻辣椒鸡"],
                ["佛跳墙","烧生糟鸭"],
                ["叫化鸡","西湖醋鱼"],
                ["盐水鸭","松鼠桂鱼"],
                ["红烧果子狸","火腿炖团鱼"]];
        var imga=[[
            ["1.jpg"],
            ["2.jpg"]],
            [["3.jpg"],
            ["4.jpg"]],
            [["5.jpg"],
            ["6.jpg"]],
            [["7.jpg"],
            ["8.jpg"]],
            [["9.jpg"],
            ["10.jpg"]],
            [["11.jpg"],
            ["12.jpg"]],
            [["13.jpg"],
            ["14.jpg"]],
            [["15.jpg"],
            ["16.jpg"]]];
        var str="";
        for(var n=0;n<caixi.length;n++){
            str=str+"<option value="+n+">"+caixi[n]+"</option>";
        }
        s1.innerHTML=str;
        str="";
        for(var n=0;n<caiming[0].length;n++){
            str=str+"<option value="+n+">"+caiming[0][n]+"</option>";
        }
    
        s2.innerHTML=str;
        var imgb ="";
         imgb=imgb+"<img src="+imga[0][0][0]+">";
         document.getElementById("d").innerHTML=imgb;
        function b1() {
            var ft = s1.value;
            var str = "";
            for (var n = 0; n < caiming[ft].length; n++) {
                str = str + "<option value=" + n + ">" + caiming[ft][n] + "</option>";
            }
            s2.innerHTML = str;
            var imgb ="";
            imgb=imgb+"<img src="+imga[ft][0][0]+">";
            document.getElementById("d").innerHTML=imgb;
        }
        function b2(){
            var ft=s1.value;
            var sd=s2.value;
            var imgb ="";
           /* alert(imga[ft][sd][0]);*/
            imgb=imgb+"<img src="+imga[ft][sd][0]+">";
            document.getElementById("d").innerHTML=imgb;
    
        }
    </script>
    
    </body>
    </html>

    使用二位数组

  • 相关阅读:
    POJ1201 Intervals & TYVJ 1589 西瓜种植 差分约束
    洛谷 P3385 【模板】负环 SPFA
    Test 2018-07-19 二中集训
    《一出好戏》一中高三学子誓师大会后记
    [NOI2012] 迷失游乐园 概率 期望 基环树DP
    codeforces CF983E NN country 树上倍增
    「Luogu P3521 [POI2011]ROT-Tree Rotations」
    「高等数学学习笔记 DAY18」
    「高等数学学习笔记 DAY17」
    「高等数学学习笔记 DAY16」
  • 原文地址:https://www.cnblogs.com/xy-milu/p/6014051.html
Copyright © 2020-2023  润新知