<form method="post" name=form action="save_info.asp"  >
     <TABLE cellSpacing=2 cellPadding=3 width="100%" border=0>
           <TR>
                <TD class=C bgColor=#FFFCF7><FONT color=#ff0000>*</FONT> 
                    <B>行业：</B></TD>
                <TD class=lh15 bgColor=#FFF8EE> 
                    <select name="p_z_Z_RootCategory" onChange="changeCategory(this)"  >
                       <option selected>--请选择行业大类--</option>
                    </select></TD>
          </TR>
          <TR>
                <TD class=lh15 bgColor=#FFF8EE> 
                    <select name="p_z_Z_CategoryId1" maxlength="80">
                       <option value="0" selected>--请选择行业子类--</option>
                    </select> 
	        </TD>
         </TR>
   </TABLE>
</FORM>
<script>
function Category(id,title) {
         this.id = id;
         this.title=title;
         this.boardlist=new Array();
         this.addBoard=addBoard;
         this.getOptions = getOptions;
        }        
        
function addBoard(board) {
         this.boardlist = this.boardlist.concat(board);
        }
        
function getOptions() {
         var tmp = new Array();
         for(var i=0; i < this.boardlist.length;i++) {
                var b = this.boardlist[i];
                tmp[i]= b.getOption();
                }
                return tmp;
        }
        
        //board methods
function Board(catid,id,title,total) 
            {                
                this.catid=catid;
                this.id=id;
                this.title=title;
                this.getOption=getOption;
            }
                
function getOption() 
            {
                return new Option(this.title,this.id);                
            }
                
        function changeCategory(list) {
        if (list.selectedIndex<=0) {
                catForm.options[0].selected=true;
                var len = boardForm.options.length;
                for (var i=len-1;i>0;i--){
                        boardForm.options[i]=null;
                }                                        
         }
        else {
                var boards = catArr[list.selectedIndex-1].getOptions();
                var len = boardForm.options.length;
                for (var i=len-1;i>0;i--){
                        boardForm.options[i]=null;
                }                
                for (var i=0;i<boards.length;i++) {
                        boardForm.options[i+1]=boards[i];
                }
                }
                boardForm.options[0].selected=true;
        }
                
function selectBoard(catid,bid,list) {
                var isExist = false; //是否是叶子类目
                for(var i=0;i<catForm.length;i++) {
                        if (catForm.options[i].value==catid) {
                                //alert("get Category");
                                catForm.options[i].selected=true;
                                changeCategory(catForm);
                                break;                        
                        }                        
                }                                
                for(var i=0;i<boardForm.length;i++) {
                        if (boardForm.options[i].value==bid) {
                                //alert("get Board");
                                boardForm.options[i].selected=true;  
                                isExist = true;                              
                                break;
                        }                        
                }   
                
                if (!isExist) {//如果是二级类目，则下拉框只显示该二级类目下所有类目                   
                    var boards = catArr[catForm.selectedIndex-1].getOptions();
                    var len = boardForm.options.length;
                    for (var i=len-1;i>0;i--){
                        boardForm.options[i]=null;
                    }     
                    var locate = 1;           
                    for (var i=0;i<boards.length;i++) {                                                              
                        if(boards[i].text.indexOf(bid) == 0){
                            boardForm.options[locate]=boards[i];
                            locate++;
                        }                                                
                    }
                
                    boardForm.options[0].selected=true;   
                }            
        }        
        var catArr = new Array();
        var cur;   
		//init catform
        var catForm = document.form.p_z_Z_RootCategory;
        var boardForm = document.form.p_z_Z_CategoryId1;
function initRootCategorys()
    {
      for (var i=0;i<catArr.length;i++) 
         {
            catForm.options[i+1]=new Option(catArr[i].title,catArr[i].id);
	 }
    }  
</script>
<script src="allCategorys.js"></script>
<script>
initRootCategorys(); 
</script>

