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

實(shí)現(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>請(qǐng)選擇</option>');
}
var arrData={
廠商1:{品牌一:'型號(hào)1-1-1,型號(hào)1-1-2',
品牌二:'型號(hào)1-2-1,型號(hào)1-2-2'},
廠商2:{品牌一:'型號(hào)2-1-1,型號(hào)2-1-2',
品牌二:'型號(hào)2-2-1,型號(hào)2-2-2'},
廠商3:{品牌一:'型號(hào)3-1-1,型號(hào)3-1-2',
品牌二:'型號(hào)3-2-1,型號(hào)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>請(qǐng)選擇</option></select>
品牌:<select id="selT"><option>請(qǐng)選擇</option></select>
型號(hào):<select id="selC"><option>請(qǐng)選擇</option></select>
<input type="button" value="查詢" id="Button1" class="btn" />
</div>
<div class="clsInit" id="divTip"></div>
</body>
</html>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 基于jquery實(shí)現(xiàn)多選下拉列表
- jQuery+Ajax請(qǐng)求本地?cái)?shù)據(jù)加載商品列表頁(yè)并跳轉(zhuǎn)詳情頁(yè)的實(shí)現(xiàn)方法
- jQuery插件select2利用ajax高效查詢大數(shù)據(jù)列表(可搜索、可分頁(yè))
- jQuery實(shí)現(xiàn)Select下拉列表進(jìn)行狀態(tài)選擇功能
- jquery實(shí)現(xiàn)圖片列表鼠標(biāo)移入微動(dòng)
- JQuery實(shí)現(xiàn)列表中復(fù)選框全選反選功能封裝(推薦)
- 基于jQuery和Bootstrap框架實(shí)現(xiàn)仿知乎前端動(dòng)態(tài)列表效果
- 利用jQuery對(duì)無(wú)序列表排序的簡(jiǎn)單方法
- 多功能jQuery樹(shù)插件zTree實(shí)現(xiàn)權(quán)限列表簡(jiǎn)單實(shí)例
- jQuery EasyUI學(xué)習(xí)教程之datagrid點(diǎn)擊列表頭排序
- jQuery實(shí)現(xiàn)列表的增加和刪除功能
相關(guān)文章
給artDialog 5.02 增加ajax get功能詳細(xì)介紹
本文將詳細(xì)介紹給artDialog 5.02 增加ajax get功能的方法,按興趣的朋友可以參考2012-11-11
jQuery實(shí)現(xiàn)點(diǎn)擊小圖片淡入淡出顯示大圖片特效
本文給大家分享基于jquery實(shí)現(xiàn)的一款圖片特效,當(dāng)點(diǎn)擊小圖片時(shí)會(huì)淡入淡出大圖片,通過(guò)定義需要展示的圖片以及圖片要展示的時(shí)間,來(lái)實(shí)現(xiàn)這一效果,感興趣的朋友跟著小編一起來(lái)學(xué)習(xí)吧2015-09-09
jQuery實(shí)現(xiàn)form表單元素序列化為json對(duì)象的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)form表單元素序列化為json對(duì)象的方法,涉及jQuery基于serializeArray方法實(shí)現(xiàn)表單序列化的相關(guān)技巧,需要的朋友可以參考下2015-12-12
解析prototype,JQuery中跳出each循環(huán)的方法
這篇文章主要介紹了在prototype,JQuery中跳出each循環(huán)的方法。需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2013-12-12
Jquery 改變r(jià)adio/checkbox選中狀態(tài),獲取選中的值(示例代碼)
這篇文章主要介紹了Jquery 改變r(jià)adio/checkbox選中狀態(tài),獲取選中的值(示例代碼) 需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2013-12-12
jquery cookie實(shí)現(xiàn)的簡(jiǎn)單換膚功能適合小網(wǎng)站
使用jquery cookie做了一個(gè)簡(jiǎn)單的換膚功能適合小網(wǎng)站并且代碼低級(jí),具體實(shí)現(xiàn)過(guò)程如下,感興趣的朋友可以了解下2013-08-08

