熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

基於JQuery的無限分級列表

2022-06-13   來源: Java核心技術 

  這是html代碼大家看個意思就可以

    <select onchange=typeChange(this)>
                             <option value=>
                                 請選擇類型
                             </option>
                             <s:iterator value=sightTypes>
                                 <option value=${id }>
                                     ${typeName }
                                 </option>
                             </s:iterator>
                        </select>

  主要思路

  列出一級列表

  AJAX查找一級列表是否有下級 有增加一個select

 function typeChange(obj){
                 var o = $(obj);
                 var value = oval();
                 var o_stId = $(#sightTypeId);
                 o_stIdval(value);
                 onextAll()remove();
                 if(value != null && value != ){
                     //有選擇 獲取下一級
                     $ajax({
                        type:POST
                        url:地址
                        data:npid= + value
                        dataType:json
                        success:function(msg){
                            if(msg != null && msglength >){
                                //有下級數據
                                var addHtml = <select onchange=\typeChange(this)\><option value=\\>請選擇類型</option>;
                                for(var i = ;i < msglength;i++){
                                    addHtml += <option value=\ + msg[i]id + \> + msg[i]typeName + </option>;
                                }
                                addHtml += </select>;
                                oafter(addHtml);
                            }else{return;}
                        }
                    });
                }
            }
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26559.html
  • 上一篇文章:

  • 下一篇文章:
  • 推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.