<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        chosen實現省市區三級聯動

        來源:懂視網 責編:小OO 時間:2020-11-27 22:09:46
        文檔

        chosen實現省市區三級聯動

        本文實例為大家分享了chosen實現省市區三級聯動的具體代碼,供大家參考,具體內容如下:效果圖。一、資源;1.1、css資源;<;link href="../../css/plugins/chosen/chosen.css" rel="stylesheet">。1.2、js資源;<;script src="../../js/plugins/chosen/chosen.jquery.js">;<;/script>。二、代碼;
        推薦度:
        導讀本文實例為大家分享了chosen實現省市區三級聯動的具體代碼,供大家參考,具體內容如下:效果圖。一、資源;1.1、css資源;<;link href="../../css/plugins/chosen/chosen.css" rel="stylesheet">。1.2、js資源;<;script src="../../js/plugins/chosen/chosen.jquery.js">;<;/script>。二、代碼;

        本文實例為大家分享了chosen實現省市區三級聯動的具體代碼,供大家參考,具體內容如下

        效果圖:

        一、資源

        1.1、css資源

        <link href="../../css/plugins/chosen/chosen.css" rel="stylesheet">

        1.2、js資源

        <script src="../../js/plugins/chosen/chosen.jquery.js"></script>

        二、代碼

        <div class="row">
         <div class="form-group col-sm-2">
         <div class="input-group">
         <select data-placeholder="選擇省份..." id="province" class="province-chosen-select" tabindex="1">
         <option value="">請選擇省份</option>
         <#if provinceList?? && provinceList?size gt 0>
         <#list provinceList as province>
         <option value="${province.provinceId!}" >${province.name!}</option>
         </#list>
         </#if>
         </select>
         </div>
         </div>
         <div class="form-group col-sm-2" style="margin-left: 36px;">
         <div class="input-group">
         <select data-placeholder="選擇城市..." id="city" class="city-chosen-select" tabindex="2">
         <option value="">請選擇城市</option>
         </select>
         </div>
         </div>
         <div class="form-group col-sm-2" style="margin-left: 36px;">
         <div class="input-group">
         <select data-placeholder="選擇區縣..." class="area-chosen-select" id="area" tabindex="3">
         <option value="">請選擇區縣</option>
         </select>
         </div>
         </div>
        </div>

        三、javascript代碼

        <script type="text/javascript">
         $(function(){
         $('.province-chosen-select').chosen({
         disable_search_threshold: 10,
         no_results_text: '沒有找到',//沒有搜索到匹配項時顯示的文字
         width: '240px',
         disable_search:false, // 設置為 true 隱藏單選框的搜索框
         disable_search_threshold:0 //少于 n 項時隱藏搜索框
         });
         $('.city-chosen-select').chosen({
         disable_search_threshold: 10,
         no_results_text: '沒有找到',//沒有搜索到匹配項時顯示的文字
         width: '240px',
         disable_search:false, // 設置為 true 隱藏單選框的搜索框
         disable_search_threshold:0 //少于 n 項時隱藏搜索框
         });
         $('.area-chosen-select').chosen({
         disable_search_threshold: 10,
         no_results_text: '沒有找到',//沒有搜索到匹配項時顯示的文字
         width: '240px',
         disable_search:false, // 設置為 true 隱藏單選框的搜索框
         disable_search_threshold:0 //少于 n 項時隱藏搜索框
         });
         
         })
         //Chosen 觸發標準的 change 事件,同時會傳遞 selected or deselected 參數, 方便用戶獲取改變的選項
         $('.province-chosen-select').on('change', function(e, params) {
         findCitiesByProvince(e, params);
         });
         $('.city-chosen-select').on('change', function(e, params) {
         findAreasByCity(e, params);
         });
         
         function findCitiesByProvince(e, params) {
         var provinceId = params.selected;
         $.post("/common/find_cities_by_province", {
         "provinceId":provinceId
         }, function(data){
         $('#city option:first').nextAll().remove();
         $('#area option:first').nextAll().remove();
         var html = '';
         for (var i = 0; i < data.length; i++) {
         html+='<option value="'+data[i].cityId+'" hassubinfo="true">'+data[i].name+'</option>'
         }
         $("#city").append(html);
         //通過 JS 改變 select 元素選項時應該觸發此事件,以更新 Chosen 生成的選框
         $('.city-chosen-select').trigger('chosen:updated');
         $('.area-chosen-select').trigger('chosen:updated');
         })
         }
         function findAreasByCity(e, params) {
         var cityId = params.selected;
         $.post("/common/find_areas_by_city", {
         "cityId":cityId
         }, function(data){
         $('#area option:first').nextAll().remove();
         var html = '';
         for (var i = 0; i < data.length; i++) {
         html+='<option value="'+data[i].areaId+'" hassubinfo="true">'+data[i].name+'</option>'
         }
         $("#area").append(html);
         //通過 JS 改變 select 元素選項時應該觸發此事件,以更新 Chosen 生成的選框
         $('.area-chosen-select').trigger('chosen:updated');
         })
         }
         function submitBtn() {
         $("#result_div").html('');
         var provinceId = $("#province").val();
         var provinceName = $("#province option:selected").text();
         var cityId = $("#city").val();
         var cityName = $("#city option:selected").text();
         var areaId = $("#area").val();
         var areaName = $("#area option:selected").text();
         $("#result_div").append("provinceId="+provinceId+"<br>")
         .append("provinceName="+provinceName+"<br>")
         .append("cityId="+cityId+"<br>")
         .append("cityName="+cityName+"<br>")
         .append("areaId="+areaId+"<br>")
         .append("areaName="+areaName+"<br>");
         }
         </script>

        四、java代碼

         /**
         *
         * @Title: findCitiesByProvince
         * @Description: 根據省份獲取城市列表
         * @author: 大都督
         * @param provinceId
         * @return
         * @return: MessageInfo
         */
         @RequestMapping("/find_cities_by_province")
         @ResponseBody
         public List<City> findCitiesByProvince(String provinceId) {
         Assert.hasText(provinceId, StringText.provinceId_must);
         return cityDao.findByProvinceId(provinceId);
         }
         /**
         *
         * @Title: findAreasByCity
         * @Description: 根據城市獲取區縣列表
         * @author: 大都督
         * @param cityId
         * @return
         * @return: List<City>
         */
         @RequestMapping("/find_areas_by_city")
         @ResponseBody
         public List<Area> findAreasByCity(String cityId) {
         Assert.hasText(cityId, StringText.cityId_must);
         return areaDao.findByCity(cityId);
         }

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        chosen實現省市區三級聯動

        本文實例為大家分享了chosen實現省市區三級聯動的具體代碼,供大家參考,具體內容如下:效果圖。一、資源;1.1、css資源;<;link href="../../css/plugins/chosen/chosen.css" rel="stylesheet">。1.2、js資源;<;script src="../../js/plugins/chosen/chosen.jquery.js">;<;/script>。二、代碼;
        推薦度:
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲日本一区二区| 亚洲av午夜福利精品一区人妖| 亚洲欧洲日产国码www| 日韩精品人妻系列无码专区免费| 亚洲成AV人片在线观看WWW| AAA日本高清在线播放免费观看| 中文字幕中韩乱码亚洲大片| 好男人视频社区精品免费| 亚洲另类精品xxxx人妖| 一级做α爱过程免费视频| 免费人成在线观看视频播放| 美女被免费网站视频在线| 亚洲国产精品一区二区第四页| 特色特黄a毛片高清免费观看| 亚洲综合精品网站在线观看| eeuss影院免费92242部| 24小时免费直播在线观看| 亚洲一区AV无码少妇电影| 又大又硬又爽免费视频| 国产成人高清精品免费观看| 久久99国产亚洲高清观看首页| 一级毛片免费观看| 亚洲一区二区免费视频| 国产在线观看免费不卡| 亚洲伊人久久大香线蕉| 欧美a级在线现免费观看| 香港经典a毛片免费观看看| 中文字幕亚洲日本岛国片| 香蕉成人免费看片视频app下载| 亚洲福利一区二区精品秒拍| 国产成人免费爽爽爽视频| 黄色毛片免费在线观看| 国产亚洲高清不卡在线观看| 国产成人精品免费视| 亚洲av日韩专区在线观看| 亚洲欧洲精品无码AV| 久久国产免费福利永久| 国产成人亚洲精品91专区高清 | 国产精品免费看久久久| jlzzjlzz亚洲乱熟在线播放| 少妇人妻偷人精品免费视频 |