如题~

解决方案 »

  1.   

    html>   
        <title>select</title>   
        <head>   
        <script language = "JavaScript">
    var onecount;
    onecount=0;
    subcat = new Array();
    subcat[0] = new Array("1","A","选项1的值");//array中第一个元素为二级菜单显示的选项,第二个元素为它上级选项的值,第三个元素为二级菜单本选项的值,下同
    subcat[1] = new Array("2","A","选项2的值");
    subcat[2] = new Array("3","A","选项3的值");
    subcat[3] = new Array("4","A","选项4的值");
    subcat[4] = new Array("10","B","选项10的值");
    subcat[5] = new Array("20","B","选项20的值");
    subcat[6] = new Array("30","B","选项30的值");
    subcat[7] = new Array("40","B","选项40的值");
    subcat[8] = new Array("100","C","选项100的值");
    subcat[9] = new Array("200","C","选项200的值");
    subcat[10] = new Array("300","C","选项300的值");
    onecount=11;
    </script>
    <script language = "JavaScript">
    function changelocation(locationid)
        {
        document.form1.select2.length = 0;     var locationid=locationid;
        var i;
        for (i=0;i < onecount; i++)
            {
                if (subcat[i][1] == locationid)
                { 
                    document.form1.select2.options[document.form1.select2.length] = new Option(subcat[i][0], subcat[i][2]);
                }        
            }
        }    
    </script>
    <body  >  <form name="form1">
    <select style="width:90" name='select1' onChange='changelocation(document.form1.select1.options[document.form1.select1.selectedIndex].value)' size='1'>
      <option value=>请选择</option>
        <option value='A'>A</option>
    <option value='B'>B</option>
    <option value='C'>C</option></select>
    <select name='select2' style="width:90">
    </select></form>     
        </body>   
        </html>   
      

  2.   

    html>   
        <title>select</title>   
        <head>   
        <script language = "JavaScript">
    var onecount;
    onecount=0;
    subcat = new Array();
    subcat[0] = new Array("1","A","选项1的值");//array中第一个元素为二级菜单显示的选项,第二个元素为它上级选项的值,第三个元素为二级菜单本选项的值,下同
    subcat[1] = new Array("2","A","选项2的值");
    subcat[2] = new Array("3","A","选项3的值");
    subcat[3] = new Array("4","A","选项4的值");
    subcat[4] = new Array("10","B","选项10的值");
    subcat[5] = new Array("20","B","选项20的值");
    subcat[6] = new Array("30","B","选项30的值");
    subcat[7] = new Array("40","B","选项40的值");
    subcat[8] = new Array("100","C","选项100的值");
    subcat[9] = new Array("200","C","选项200的值");
    subcat[10] = new Array("300","C","选项300的值");
    onecount=11;
    </script>
    <script language = "JavaScript">
    function changelocation(locationid)
        {
        document.form1.select2.length = 0;     var locationid=locationid;
        var i;
        for (i=0;i < onecount; i++)
            {
                if (subcat[i][1] == locationid)
                { 
                    document.form1.select2.options[document.form1.select2.length] = new Option(subcat[i][0], subcat[i][2]);
                }        
            }
        }    
    </script>
    <body  >  <form name="form1">
    <select style="width:90" name='select1' onChange='changelocation(document.form1.select1.options[document.form1.select1.selectedIndex].value)' size='1'>
      <option value=>请选择</option>
        <option value='A'>A</option>
    <option value='B'>B</option>
    <option value='C'>C</option></select>
    <select name='select2' style="width:90">
    </select></form>     
        </body>   
        </html>