• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • Javascript 實現下拉列表連動,提示:Array not defined

    發表于:2007-06-21來源:作者:點擊數: 標簽:
    有一個應用,要求一個下拉列表(class1)的變化觸發另一個依賴列表(class2)的變化。參照《下拉框連動( 數據庫 版)》,有以下程序片段: % sql = select id, name, substring(id,1,2) bigclass from classone where type=1 order by id set rs = session(co

       


    有一個應用,要求一個下拉列表(class1)的變化觸發另一個依賴列表(class2)的變化。參照《下拉框連動(數據庫版)》,有以下程序片段:

    <% sql = "select id, name, substring(id,1,2) bigclass from classone where type='1' order by id"
    set rs = session("conn").execute(sql)
    %>

    <script language="javascript">
    var onecount = 0;
    subcat = new array(); <---------提示:array 未定義------------

    <% count = 0
    do while not rs.eof <--------- rs 已經是前面定義的recordset
    %>
    subcat[<%=count%>] = new array("<%=trim(rs("name"))%>","<%=trim(rs("bigclass"))%>","<%=trim(rs("id"))%>");
    <% count = count+1
    rs.movenext
    loop
    rs.close
    set rs = nothing
    %>
    onecount = <%=count%>

    function chgcls(){
    for (var i=document.search.class2.options.length; i>0; i--){
    document.search.class2.options[i]=null;
    }
    for (i = 0; i<onecount; i++){
    bigclass = "'"&subcat[i][1]&"'";
    if (document.search.class1.options[document.search.class1.selectedindex].value==bigclass){
    document.search.class2.options[document.search.class2.length]=new option(subcat[i,0],subcat[i,2]);
    }
    }
    }
    </script>

    下面是調用該函數的HTML語句:
    。。。
    <form id="search" name="search" method="post" action="query.asp">
    <select name="class1" size=1 width=16 onchange="chgcls(document.search.class1.options[document.search.class1.selectedIndex].value)">
    <%
    Response.Write "<option selected value=''></option>"
    sql="select id,name from classone where substring(id,3,1)='' order by id" '取設備代碼的前兩位
    set menurs=session("conn").execute(sql)
    do while not menurs.eof
    Response.Write "<option value="&trim(menurs("id"))&">"&trim(menurs("name"))&"</option>"
    menurs.movenext
    loop
    menurs.close
    set menurs=nothing
    %></select>

    <select name="class2" size=1 width=16>
    <option selected value=""></option>
    </select>
    .....
    </form>

    問題1:我在加入下列JavaScript 后,“array 未定義”不再出現,是否是JAVASCRIPT 本身的要求,還是與瀏覽器的版本有關?(我用IE4)
    function array() {
    this.length = array.arguments.length
    for (var i = 0; i< this.length; i++) this[i+1] = array.arguments[i];
    }

    問題2:但是卻提示:
    document.search.class1.options[...].value 不是對象
    為什么?
    .......

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>