<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript">
/**
* html
* -------------------------
* 琛屾斂鍖哄垝浠g爜:
* <input id="xzqhcode1" size=6 readonly>
* <select id="sj_select1"></select>
* <select id="sx_select1"></select>
*
* javascript
* --------------------------
* var s1 = new LDSelect("xzqhcode1","sj_select1","sx_select1");
* s1.updateByCode(341202);
**/
var ah_sx_data={
340000:{name:"瀹夊窘鐪?,data:["340000:瀹夊窘鐪?]},
340100:{name:"鍚堣偉甯?,data:["340100:鍚堣偉甯?,"340101:甯傝緰鍖?,"340102:鐟舵捣鍖?,"340103:搴愰槼鍖?,"340104:铚€灞卞尯"]},
340200:{name:"鑺滄箹甯?,data:["340200:鑺滄箹甯?,"340201:甯傝緰鍖?,"340202:闀滄箹鍖?,"340203:寮嬫睙鍖?,"340207:楦犳睙鍖?]},
340300:{name:"铓屽煚甯?,data:["340300:铓屽煚甯?,"340301:甯傝緰鍖?,"340302:榫欏瓙婀栧尯","340303:铓屽北鍖?,"340304:绂逛細鍖?]}
}
function LDSelect(targetCode,s1,s2){
var _get = function(id){
return document.getElementById(id);
};
var changeXJSelect=function(){
var xj_select = _get(s2);
_get(targetCode).value=xj_select.value;
}
//鍒锋柊鍘跨骇涓嬫媺妗?br> var reBuildXJSelect=function(){
var curr_select = _get(s1)
var curr_id = curr_select.options[curr_select.selectedIndex].value;
for(var sxCode in ah_sx_data){
if(sxCode == curr_id){
var xj_select = _get(s2);
xj_select.options.length = 0;
var data = ah_sx_data[sxCode].data;
for(var i=0;i<data.length;i++){
var sp = data[i].split(":");
xj_select.options.add(new Option(sp[1],sp[0]));
}
changeXJSelect();
break;
}
}
}
//鍒濆鍖栧競绾т笅鎷夋
void function(){
var sj_select = _get(s1);
sj_select.onchange = reBuildXJSelect;
_get(s2).onchange = changeXJSelect;
for(var s in ah_sx_data){
var varItem = new Option(ah_sx_data[s].name,s);
sj_select.options.add(varItem);
}
reBuildXJSelect();
}();
return{
updateByCode:function(qxcode){
outerfor:
for(var s in ah_sx_data){
var data = ah_sx_data[s].data;
for(var i=0;i<data.length;i++){
if(data[i].split(":")[0] == qxcode){
_get(s1).value = s;
reBuildXJSelect();
break outerfor;
}
}
}
_get(s2).value = qxcode;
_get(targetCode).value=qxcode;
}
}
}
window.onload=function(){
var s1 = new LDSelect("xzqhcode1","sj_select1","sx_select1");
s1.updateByCode(340207);
}
</script>
琛屾斂鍖哄垝浠g爜:
<input id="xzqhcode1" size=6 readonly>
<select id="sj_select1"></select>
<select id="sx_select1"></select>