handmoving 2015-04-28 13:19 采纳率: 100%
浏览 1784
已采纳

求一个简单点的,根据下拉列表内容,在jsp页面输出List的一个小项目

我还是个菜鸟,求给的东西简单易懂,有一些介绍是最好的。谢谢!

  • 写回答

3条回答 默认 最新

  • tsinggao 2015-04-28 16:15
    关注
     <script>
        function showList()
        {
            document.getElementById("div0").style.display = "none";
            document.getElementById("div1").style.display = "none";
            document.getElementById("div2").style.display = "none";
            if(document.getElementById("dishType").value==0)
            {           
                document.getElementById("div0").style.display = "block";
            }
            if(document.getElementById("dishType").value==1)
            {           
                document.getElementById("div1").style.display = "block";
            }
            if(document.getElementById("dishType").value==2)
            {           
                document.getElementById("div2").style.display = "block";
            }
        }
    </script>
    
    
    <html>
      <head>    
        <title>根据菜系点餐</title>   
      </head>
    
      <body>
        <br>
        <br>
        <div align="center"><h1>请选择菜系:</h1></div>
        <br>
        <div align="center">
        <select id="dishType" name="dishType" style="width:300px;height:30px" onchange="javascript:showList();">
            <option value=0 selected></option>
            <option value=1>湘菜</option>
            <option value=2>川菜</option>
        </select>
        </div>
        <hr/>
        <br>
        <br>
        <br>
        <br>
    
        <div id="div0">
            <table align="center" width="500px" border="1">
                <tr>
                    <td width="20%" height="30px">序号</td>
                    <td width="40%" height="30px">菜名</td>
                    <td width="40%" height="30px">价格</td>               
                </tr>
            </table>
        </div>
        <div id="div1" style="display:none">
            <table align="center" width="500px" border="1">
                <tr>
                    <td width="20%" height="30px">序号</td>
                    <td width="40%" height="30px">菜名</td>
                    <td width="40%" height="30px">价格</td>               
                </tr>
                <tr>
                    <td width="20%" height="30px">1</td>
                    <td width="40%" height="30px">小炒肉</td>
                    <td width="40%" height="30px">28元</td>                
                </tr>
                <tr>
                    <td width="20%" height="30px">2</td>
                    <td width="40%" height="30px">毛家红烧肉</td>
                    <td width="40%" height="30px">48元</td>                
                </tr>
                <tr>
                    <td width="20%" height="30px">3</td>
                    <td width="40%" height="30px">腊味合蒸</td>
                    <td width="40%" height="30px">38元</td>                
                </tr>
            </table>
        </div>
        <div id="div2" style="display:none">
            <table align="center" width="500px" border="1">
                <tr>
                    <td width="20%" height="30px">序号</td>
                    <td width="40%" height="30px">菜名</td>
                    <td width="40%" height="30px">价格</td>               
                </tr>
                <tr>
                    <td width="20%" height="30px">1</td>
                    <td width="40%" height="30px">麻婆豆腐</td>
                    <td width="40%" height="30px">18元</td>                
                </tr>
                <tr>
                    <td width="20%" height="30px">2</td>
                    <td width="40%" height="30px">水煮肉片</td>
                    <td width="40%" height="30px">38元</td>                
                </tr>
                <tr>
                    <td width="20%" height="30px">3</td>
                    <td width="40%" height="30px">宫保鸡丁</td>
                    <td width="40%" height="30px">28元</td>                
                </tr>
            </table>
        </div>
        <div id="div3" style="display:none"></div>
        <div id="div4" style="display:none"></div>
      </body>
    </html>
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)