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

jQuery實現(xiàn)聯(lián)動下拉列表查詢框

 更新時間:2017年01月04日 15:23:44   作者:小伍  
這篇文章主要為大家詳細介紹了jQuery實現(xiàn)聯(lián)動下拉列表查詢框,具有一定的參考價值,感興趣的小伙伴們可以參考一下

在查詢與列表顯示的時候經(jīng)常用到聯(lián)動列表顯示,比如一級選項是國家,二級選項是省,三級是市,這樣的聯(lián)動是聯(lián)系的實時導(dǎo)出的,比如你不可能選擇了四川省卻在三級聯(lián)動欄中出現(xiàn)濟南市,這樣的聯(lián)動實現(xiàn)方法如下:

效果圖示:

實現(xiàn)源代碼:

<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title></title>
 <meta name="keywords" content=" keywords" />
 <meta name="description" content="description" />
</head>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<style type="text/css">
 body{font-size:13px}
 .clsInit{width:435px;height::35px;line-height:35px;padding-left:10px}
 .clsTip{padding-top:5px;background-color:#eee;display:none}
 .btn{border:solid 1px #666;padding:2px;width:65px;float:right;margin-top:6px;margin-right:6px;filter:progid:DXImageTransform.Mcrosoft.Gradient(GraientType=0,StartColorStr=#FFFFFF,EndColorStr=#ECE9D8);}
</style>
<body>
<script type="text/javascript">
 $(function(){
  function objInit(obj){
   return $(obj).html('<option>請選擇</option>');
  }
  var arrData={
   廠商1:{品牌一:'型號1-1-1,型號1-1-2',
     品牌二:'型號1-2-1,型號1-2-2'},
   廠商2:{品牌一:'型號2-1-1,型號2-1-2',
     品牌二:'型號2-2-1,型號2-2-2'},
   廠商3:{品牌一:'型號3-1-1,型號3-1-2',
     品牌二:'型號3-2-1,型號3-2-2'}
  };
  $.each(arrData,function(pF){
   $('#selF').append('<option>'+pF+'</option>');
  });
  $('#selF').change(function(){
   objInit('#selT');
   objInit('#selC');
   $.each(arrData,function(pF,pS){
    if($('#selF option:selected').text()==pF){
     $.each(pS,function(pT,pC){
      $('#selT').append('<option>'+pT+'</option>');
     });
     $('#selT').change(function(){
      objInit('#selC');
      $.each(pS,function(pT,pC){
       if($('#selT option:selected').text()==pT){
        $.each(pC.split(","),function(){
         $('#selC').append('<option>'+this+'</option>');
        })
       }
      })
      
     });
    }
   })
  });
 });
</script>

<div class="clsInit">

 廠商:<select id="selF"><option>請選擇</option></select>
 品牌:<select id="selT"><option>請選擇</option></select>
 型號:<select id="selC"><option>請選擇</option></select>
 <input type="button" value="查詢" id="Button1" class="btn" />
</div>
<div class="clsInit" id="divTip"></div>

</body>
</html>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論