联系官方销售客服

1835022288

028-61286886

POSCMS分享经验 版主:论坛审计组
按联动菜单搜索的用例分享【转】
类型:POSCMS 更新时间:2018-03-11 21:11:45

<!--按联动菜单搜索-->

<p style="line-height:30px">

    <strong>按联动菜单搜索:</strong>

    <a class="label {if !$params.school|| dr_linkage('address', $params.school, 0, 'child')}label-success{else}label-default{/if}"  target="_blank"  target="_blank" href="{dr_search_url($params, 'school', NULL)}">不限</a>


<!--调用联动菜单address,pid为动态获取的地区id-->

    {list action=linkage code=school pid=$params.school}

    <a class="label {if $t.id==$params.school}label-success{else}label-default{/if}"  target="_blank"  target="_blank" href="{dr_search_url($params, 'school', $t.id)}">{$t.name}</a>

    {/list}

</p>


回帖
  • xgocn
    #1楼    xgocn
    2018-01-03 18:00:47
    0
    这是一个动态级联的联动菜单用法<div class="form-group" id="dr_row_order_city"><div class="col-md-10"><input type="hidden" name="data[order_city]" id="dr_order_city" value="0"><script type="text/javascript" src="/statics/js/jquery.ld.js"></script><span id="dr_linkage_order_city_select" style=""><label style="padding-right:10px;"><select class="form-control finecms-select-order_city" name="order_city-1" id="order_city-1" width="100" ><option value=""> -- </option></select></label><label style="padding-right:10px;"><select class="form-control finecms-select-order_city" name="order_city-2" id="order_city-2" width="100" style="display:none"><option value=""> -- </option></select></label><label style="padding-right:10px;"><select class="form-control finecms-select-order_city" name="order_city-3" id="order_city-3" width="100" style="display:none"><option value=""> -- </option></select></label></span><script type="text/javascript"> function dr_linkage_select_order_city() { $("#dr_linkage_order_city_select").show(); $("#dr_linkage_order_city_cxselect").hide(); } $(function(){ var $ld5 = $(".finecms-select-order_city"); $ld5.ld({ajaxOptions:{"url": "/index.php?s=member&c=api&m=linkage&code=address"},defaultParentId:0}) var ld5_api = $ld5.ld("api"); ld5_api.selected(); $ld5.bind("change",onchange); function onchange(e){ var $target = $(e.target); var index = $ld5.index($target); //$("#order_city-4").remove(); $("#dr_order_city").val($ld5.eq(index).show().val()); index ++; $ld5.eq(index).show(); } })</script></div></div>
  • 农村人
    #2楼    农村人
    2018-01-03 19:57:02
    0
    厉害
  • xgocn
    #3楼    xgocn
    2018-01-04 09:00:54
    0
    又一个<body> <div class="selectList form-group"><div class="col-md-10"><label style="padding-right:10px;"> <select class="province form-control"> <option>请选择</option> </select></label><label style="padding-right:10px;"> <select class="city form-control"> <option>请选择</option> </select></label><label style="padding-right:10px;"> <select class="district form-control"> <option>请选择</option> </select></label> </div> <script type="text/javascript"> $(function(){ $(".selectList").each(function(){ var url = "area.json"; var areaJson; var temp_html; var oProvince = $(this).find(".province"); var oCity = $(this).find(".city"); var oDistrict = $(this).find(".district"); //初始化省 var province = function(){ $.each(areaJson,function(i,province){ temp_html+="<option value='"+province.p+"'>"+province.p+"</option>"; }); oProvince.html(temp_html); city(); }; //赋值市 var city = function(){ temp_html = ""; var n = oProvince.get(0).selectedIndex; $.each(areaJson[n].c,function(i,city){ temp_html+="<option value='"+city.ct+"'>"+city.ct+"</option>"; }); oCity.html(temp_html); district(); }; //赋值县 var district = function(){ temp_html = ""; var m = oProvince.get(0).selectedIndex; var n = oCity.get(0).selectedIndex; if(typeof(areaJson[m].c[n].d) == "undefined"){ oDistrict.css("display","none"); }else{ oDistrict.css("display","inline"); $.each(areaJson[m].c[n].d,function(i,district){ temp_html+="<option value='"+district.dt+"'>"+district.dt+"</option>"; }); oDistrict.html(temp_html); }; }; //选择省改变市 oProvince.change(function(){ city(); }); //选择市改变县 oCity.change(function(){ district(); }); //获取json数据 $.getJSON(url,function(data){ areaJson = data; province(); }); }); }); </script> </div>area.json[ {"p":"江西省", "c":[ {"ct":"南昌市", "d":[ {"dt":"西湖区"}, {"dt":"东湖区"}, {"dt":"高新区"} ]}, {"ct":"赣州市", "d":[ {"dt":"瑞金县"}, {"dt":"南丰县"}, {"dt":"全南县"} ]} ]}, {"p":"北京", "c":[ {"ct":"东城区"}, {"ct":"西城区"} ]}, {"p":"河北省", "c":[ {"ct":"石家庄", "d":[ {"dt":"长安区"}, {"dt":"桥东区"}, {"dt":"桥西区"} ]}, {"ct":"唐山市", "d":[ {"dt":"滦南县"}, {"dt":"乐亭县"}, {"dt":"迁西县"} ]} ]}]
  • 技佳科技
    #4楼    技佳科技
    2018-01-04 15:05:56
    0
    楼主配图最好
  • 朱田志
    #5楼    朱田志
    2018-03-11 21:11:45
    0
    楼主加QQ聊下呗 ,我有这个功能的需求!