級聯

 

個人是新增和修改在一個頁面,因此在寫的時候若是是修改就將此值顯示html

 

js:ui

 1 changeLevel :function(systemLevel) {
 2 
 3 var arr=new Array(); 
 4 arr["幹線"]= ["省際一干", "省內二幹"]; 
 5 arr["本地網"] = ["本地骨幹", "本地匯聚","本地接入"]; 
 6 arr["集客"] = ["集客專線"]; 
 7 arr["駐地網"]= ["駐地網主幹", "駐地網配線"]; 
 8 document.getElementById("system_level").options.length = 1;
 9 var projectType=document.getElementById("project_type").value;
10 if(projectType!=""){
11 
12 for(var i=0;i<arr[projectType].length;i++){
13 if(systemLevel==arr[projectType][i]){
14 
15 document.getElementById("system_level").options.add(new Option(
16 arr[projectType][i], arr[projectType][i],true,true));//後面的兩個 true 是默認選中
17 }else{
18 document.getElementById("system_level").options.add(new Option(
19 arr[projectType][i], arr[projectType][i]));
20 }
21 } 
22 } 
23 }

 

html:spa

 

 1 <td class="label"><span class="text_red">*</span><label for="a0_project_type">工程類型:</label></td>
 2                     <td><select name="a0_project_type" data-type="required" id="project_type" data-action="changeLevel" >
 3                             <option value="">請選擇</option>
 4                            <%if(duct.a0_project_type == '幹線'){%>
 5                                 <option value="幹線" selected>幹線</option>
 6                             <%}else{%>
 7                                 <option value="幹線">幹線</option>
 8                             <%}%>
 9                             
10                             <%if(duct.a0_project_type == '本地網'){%>
11                                 <option value="本地網" selected>本地網</option>
12                             <%}else{%>
13                                 <option value="本地網">本地網</option>
14                             <%}%>
15                             
16                             <%if(duct.a0_project_type == '集客'){%>
17                                 <option value="集客" selected>集客</option>
18                             <%}else{%>
19                                 <option value="集客">集客</option>
20                             <%}%>
21                             
22                             <%if(duct.a0_project_type == '駐地網'){%>
23                                 <option value="駐地網" selected>駐地網</option>
24                             <%}else{%>
25                                 <option value="駐地網">駐地網</option>
26                             <%}%>
27                             
28                     </select></td>
29                                     
30                     <td class="label">
31                         <span class="text_red">*</span>
32                         <label for="a0_system_level">光纜級別:</label>
33                     </td>
34                     <td>
35                         <select name="a0_system_level" data-type="required" id="system_level">
36                             <option value="">請選擇</option>
37                                             
38                           <%if(duct.a0_system_level == '省際一干'){%>
39                                 <option value="省際一干" selected>省際一干</option>
40                             <%}%>                                
41                             <%if(duct.a0_system_level == '省內二幹'){%>
42                                 <option value="省內二幹" selected>省內二幹</option>
43                             <%}%>
44                             <%if(duct.a0_system_level == '本地骨幹'){%>
45                                 <option value="本地骨幹" selected>本地骨幹</option>
46                             <%}%>
47                             <%if(duct.a0_system_level == '本地匯聚'){%>
48                                 <option value="本地匯聚" selected>本地匯聚</option>
49                             <%}%>
50                             <%if(duct.a0_system_level == '本地接入'){%>
51                                 <option value="本地接入" selected>本地接入</option>
52                             <%}%>
53                             <%if(duct.a0_system_level == '集客專線'){%>
54                             <option value="集客專線" selected>集客專線</option>
55                             <%}%>                            
56                             <%if(duct.a0_system_level == '駐地網主幹'){%>
57                                 <option value="駐地網主幹" selected>駐地網主幹</option>
58                             <%}%>
59                             <%if(duct.a0_system_level == '駐地網配線'){%>
60                                 <option value="駐地網配線" selected>駐地網配線</option>
61                             <%}%>
62                         </select>
63                     </td>    
相關文章
相關標籤/搜索