function InitData(depth,parent,id)
          {
              var ele = document.getElementById(id);
              if(depth==1)
              {
                  for(var i=0;i<firstSort.length;i++)
                  {
                  if(firstSort[i][0]==parent)
                  ele.options.add(new Option(firstSort[i][2],firstSort[i][1]));
                  }
              }
              else if(depth==2)
              {
                  ele.options.length=0;
                  for(var i=0;i<secondSort.length;i++)
                  {
                  if(secondSort[i][0]==parent)
                  ele.options.add(new Option(secondSort[i][2],secondSort[i][1]));
                  }
                  ele.options.selectedIndex=0;
              }
              else if(depth==3)
              {
                  ele.options.length=0;
                  for(var i=0;i<thirdSort.length;i++)
                  {
                  if(thirdSort[i][0]==parent)
                  ele.options.add(new Option(thirdSort[i][2],thirdSort[i][1]));
                  }
                  ele.options.selectedIndex=0;
              }
          }
          InitData("1","0","LbFirst");
          function secondSelect(first,second,third)
          {
              var tempSecIndex="";
              var tempThirIndex="";
              try{
               tempSecIndex = document.getElementById(first).options[document.getElementById(first).selectedIndex].value;
              }
              catch(e){
              tempSecIndex=0;
              }
              try{
               tempThirIndex = document.getElementById(second).options[document.getElementById(second).selectedIndex].value;
              }
              catch(e){
              tempThirIndex=0;
              }
              InitData("2",tempSecIndex,second);
              InitData("3",tempThirIndex,third);
          }
          function thirdSelect(parentId,selectId)
          {
              var tempSecIndex;
              try{
              tempSecIndex =  document.getElementById(parentId).options[document.getElementById(parentId).selectedIndex].value;
              }
              catch(e){
              tempSecIndex=0;
              }
              InitData("3",tempSecIndex,selectId)
          }
          function allsort()
          {
          var tempFir= document.getElementById("LbFirst").options[document.getElementById("LbFirst").selectedIndex].value;
          var tempSec= document.getElementById("LbSecond").options[document.getElementById("LbSecond").selectedIndex].value;
          alert(document.getElementById("LbThird").selectedIndex);
          var tempThir= document.getElementById("LbThird").selectedIndex>-1?(document.getElementById("LbThird").options[document.getElementById("LbThird").selectedIndex].value):(0);
          selectIndex("LbFirst",tempFir,"LbSecond",tempSec,"LbThird",tempThir);
          }
          function selectIndex(firId,firSort,secId,secSort,thirId,thirSort)
          {
              if(firSort.length>0){     
                 listSelect(firId,firSort)
              }
              if(secSort.length>0){  
               secondSelect(firId,secId,thirId)  
                 listSelect(secId,secSort)
              }
              if(thirSort.length>0){   
               thirdSelect(secId,thirId) 
                 listSelect(thirId,thirSort)
              }
          }
          function listSelect(lId,lSort)
          {
           var firSortEle = document.getElementById(lId).options;
                 for(var i=0;i<firSortEle.length;i++){
                if(firSortEle[i].value==lSort){
                firSortEle[i].selected=true;
                break;
                }   
               }
          }
          selectIndex("LbFirst","6A726A","LbSecond","47E3B5","LbThird","19F5F1");
          posted on 2009-03-28 18:29 sanmao 閱讀(123) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 建瓯市| 乐昌市| 隆安县| 岑巩县| 邵阳市| 惠来县| 双流县| 黄大仙区| 宁波市| 吉木乃县| 屏山县| 阿瓦提县| 小金县| 武鸣县| 琼结县| 普兰店市| 酉阳| 绥棱县| 德安县| 内江市| 本溪| 昔阳县| 阜阳市| 潜江市| 新津县| 内江市| 遂川县| 西峡县| 铜鼓县| 沧州市| 陵水| 遵义县| 栾川县| 郸城县| 尼勒克县| 江山市| 兰州市| 民县| 论坛| 赣州市| 丰顺县|