?<body>? ?<select id="s1"><option>-請(qǐng)選擇-</option></select> ? <select id="s2"><option>-請(qǐng)選擇-</option></select> ? <select id="s3"><option>-請(qǐng)選擇-</option></select> <script> var arr1=["黑龍江省",'吉林省','北京'];? ? ?var arr2=[? ? ? ? ['哈爾濱','訥河','黑河'],? ? ? ? ['長(zhǎng)春','吉林市','白城'],? ? ? ? ['海淀區(qū)','朝陽(yáng)區(qū)','房山']? ?];? ?var arr3=[? ? ? ? ? ? [['香房','動(dòng)力','道里'],['訥河1','訥河2','訥河3'],['黑河1','黑河2','黑河3']],? ? ? ? [['長(zhǎng)春1','長(zhǎng)春2','長(zhǎng)春3'],['吉林市1','吉林市2','吉林市3'],['白城1','白城2','白城3']],? ? ? ? [['海淀區(qū)1','海淀區(qū)1','海淀區(qū)1'],['朝陽(yáng)區(qū)1','朝陽(yáng)區(qū)1','朝陽(yáng)區(qū)1'],['房山1','房山2','房山3']],? ? ? ? ? ? ?];? ?function $(id){ return document.getElementById(id);? ?}function superMan(arr,ele){for(var i=0;i<arr.length;i++ ){ var option=document.createElement('option'); option.innerHTML=arr[i]; option.value=i; ele.appendChild(option); } ?}window.onload=function (){ var s1=$('s1'); s1.onchange=changeCity; while(s1.children.length>1){ s1.removeChild(s1.lastElementChild); } superMan(arr1,s1);}?var n=null;//索引function changeCity(){ var s2=$('s2'); s2.onchange=changeQu; while(s2.children.length>1){ s2.removeChild(s2.lastElementChild); }?n=this.value;//索引 var ar=arr2[n]; superMan(ar,s2);}function changeQu(){ var s3=$('s3'); while(s3.children.length>1){ s3.removeChild(s3.lastElementChild); } var arrr=arr3[n][this.value]; console.log(arrr);?superMan(arrr,s3);}</script>?</body>我想知道var arrr=arr3[n][this.value];的含義,以及各個(gè)步驟的大概意思
關(guān)于下拉菜單三級(jí)聯(lián)動(dòng)
二露
2017-05-25 20:00:20