类似下拉列表框的联动效果,比如选择一个下拉框的option,第二个下拉列表就自动加载该选项的子选项option,我要做的不是下拉框的这种,我要用复选框(checkbox)做多项选择,不管选中哪一项(可以多选)都要在下一级列表显示出被选中的checkbox的子项内容,并且子项也是checkbox,也可以多选。提交表单的时候要能获取到被选中的checkbox的值.可以到http://www.foodqs.com看看,用户名:b4ys  密码:3065。效果位置:商业机会/发布商机,下拉框换成复选框,这个网站用的是iframe,在firefox下不支持,我想用div.我是菜鸟,请高手帮忙......例如:父级复选框:1.中国
2.德国
3.加拿大
......
n.美国
子级复选框:父级菜单没有选择是,这里没有复选框,如果选中1、2、3,3个父级复选框的话 就在此列出所有属于这三个国家的城市。
中国>>北京
中国>>上海
中国>>香港
德国>>柏林
加拿大>>多伦多
加拿大>>渥太华
加拿大>>蒙特利尔 

解决方案 »

  1.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>new page</title>
    <script>
    var cityArray=new Array();
    cityArray[0]=["北京","上海","香港"];
    cityArray[1]=["柏林"];
    cityArray[2]=["多伦多","渥太华","蒙特利尔"];
    function changeValue(value){
    document.getElementById("s").innerHTML="";
    var select=document.getElementById("s");
    for(var i=0;i<cityArray[value].length;i++){
    var option=new Option(cityArray[value][i],cityArray[value][i]);
    select.options.add(option);
    }
    }
    </script>
    </head>
    <body>
    国家:<select onchange="changeValue(this.value)">
    <option value="0">中国</option>
    <option value="1">德国</option>
    <option value="2">加拿大</option>
    </select><br>
    城市:<select id=s>
    <option>北京</option>
    <option>上海</option>
    <option>香港</option>
    </select>
    </body>
    </html>
      

  2.   

    不是二楼的效果,二楼做的是下拉框效果,我需要的是复选框列表类型的,可以到http://www.foodqs.com看看,用户名:b4ys  密码:3065。效果位置:商业机会/发布商机,下拉框换成复选框,这个网站用的是iframe,在firefox下不支持,我想用div
      

  3.   

    var checksb = document.createElement("input");   
      checksb.type = "checkbox";   
      checksb.id = "mychecks";   
      document.getElementById("form1").appendChild(checksb);
      

  4.   

    急啊,怎么解决,能否把代码都贴出来,我是javascript菜鸟,请高手帮忙啊
      

  5.   

    这是我写的代码,请帮忙看看怎么修改才能实现效果,谢谢各位大虾了
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <!--#Include file="Conn.inc"--><html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>测试</title>
    </head><body>
    <Script language="javascript">
    <!--
     function checkCountry()
     {
         var div = document.createElement('div')
        var input = document.createElement('input')
         input.type = 'checkbox'
         input.checked = true
        div.appendChild(input)
         document.body.appendChild(input)
        //input.checked = true
     }
    var Country = document.getElementsByName('Country');
    var StateDiv = document.getElementById('StateDiv');
        var State = document.createElement('input');
    State.type = "checkbox";
    State.id = "States";
    State = new Array();
    var Countrys = new Array();
    Country.type='checkbox';
    var i;
    for (i = 0; i<Country.length; i++)
    {    Countrys[i] = Country[i].value;
         if (Country[i].checked == true)
       {
          Countries=Countrys[i]
      <%
       Set Rs=Server.Createobject("adodb.recordset")
           Sql="select * from States where Countries='"&Countries&"'"
       Rs.open Sql,conn,1,1
       Recordscount=Rs.recordcount
                   Do while Not rs.bof and Not rs.eof and J < Recordscount
       %>
       
        State[i][j]=<%=Rs("States")%>
    document.body.appendChild(State);
    <%
     J=J+1
     Rs.movenext
     loop
    %>
            
        } 
     }
     }
     
    //-->
    </Script><form name="shipping" id="shipping" method="post" action="1.asp?action=save">
    <div id="CountryDiv" style="width:180px;height:160px;overflow:auto;border: 2px inset #FFFFFF;">
    <%
    Set Rs=Server.Createobject("adodb.recordset")
        Sql="select * from Countries order by Countries asc"
        Rs.open Sql,conn,1,1
    Do while Not Rs.bof and Not Rs.eof
    %>
    <input type="checkbox" name="Country" id="Country" value="<%=Rs("Countries")%>" onclick="checkCountry()" border="1"/><%=Rs("Countries")%><br>
    <%
        Rs.movenext
        loop
    %>
    </div>
    <div id="StateDiv" style="width:180px;height:160px;overflow:auto;border: 2px inset #FFFFFF;">
    </div>
    </form>
    </body>
    </html>
      

  6.   

    我看了看,因为在学ajax,用ajax来做还是比较简单的。
      

  7.   

    问下楼主!! 你实现了吗?/? 具体怎么实现的发给我看看呗...
    [email protected]