欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

超簡(jiǎn)單JS二級(jí)、多級(jí)聯(lián)動(dòng)的簡(jiǎn)單實(shí)例

 更新時(shí)間:2014年02月18日 09:04:31   作者:  
本篇文章主要是對(duì)超簡(jiǎn)單JS二級(jí)、多級(jí)聯(lián)動(dòng)的簡(jiǎn)單實(shí)例進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助
超簡(jiǎn)單的JS聯(lián)動(dòng)代碼,不過要配合jquery用,也可以自己修改為不用任選JS庫(kù)的代碼
復(fù)制代碼 代碼如下:

<tr>
  <th>一級(jí)分類</th><td>
    <select name="subsidiary_cat_id" class="subsidiary_cat_id" onchange="linkage('.subsidiary_cat_id','.cat_id');">
      <option>請(qǐng)選擇</option>
    </select>
    <script language="javascript">
    var linkage_data={$list_file_category};//初始化級(jí)聯(lián)數(shù)據(jù),{$list_file_category}是PHP的JSON_ENCODE的數(shù)據(jù),數(shù)組有3個(gè)數(shù)據(jù),id,parent_id,name
    function linkage(parent_dom,son_dom){
        var parent_id=0;
        if(parent_dom){
            parent_id=$(parent_dom).val();   
        }
        $(son_dom).empty();//先清空下拉
        var html='<option>請(qǐng)選擇</option>';
        $.each(linkage_data,function(key,value){
            if(value.parent_id==parent_id){
                html+="<option value='"+value.id+"'>"+value.name+"</option>";
            }
        });
        $(son_dom).append(html);
    }
    linkage('',".subsidiary_cat_id")//不傳上級(jí)節(jié)點(diǎn),表示為第一級(jí)數(shù)據(jù)
    </script>
    </td></tr>
<tr><th>二級(jí)目錄</th><td>
  <select name="cat_id" class="cat_id">
    <option>請(qǐng)選擇</option>
  </select></td></tr>

相關(guān)文章

最新評(píng)論