Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Coding Error? Dynamic Listboxes

    I've written code to create 3 dynamic listboxes

    Order

    Family

    Genus

    All i get is a blank page when i try to go to it. I can't see the error, i've defined all of my variables. The Code is below.

    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!--#include file="Connections/ProtoUcamara.asp" -->
    <%
    Dim rsOrder
    Dim rsOrder_numRows
    
    Set rsOrder = Server.CreateObject("ADODB.Recordset")
    rsOrder.ActiveConnection = MM_ProtoUcamara_STRING
    rsOrder.Source = "SELECT *  FROM [Order]  ORDER BY Relation ASC"
    rsOrder.CursorType = 0
    rsOrder.CursorLocation = 2
    rsOrder.LockType = 1
    rsOrder.Open()
    
    rsOrder_numRows = 0
    %>
    <%
    Dim rsFamily
    Dim rsFamily_numRows
    
    Set rsFamily = Server.CreateObject("ADODB.Recordset")
    rsFamily.ActiveConnection = MM_ProtoUcamara_STRING
    rsFamily.Source = "SELECT * FROM Family ORDER BY Relation ASC"
    rsFamily.CursorType = 0
    rsFamily.CursorLocation = 2
    rsFamily.LockType = 1
    rsFamily.Open()
    
    rsFamily_numRows = 0
    %>
    <%
    Dim rsGenus
    Dim rsGenus_numRows
    
    Set rsGenus = Server.CreateObject("ADODB.Recordset")
    rsGenus.ActiveConnection = MM_ProtoUcamara_STRING
    rsGenus.Source = "SELECT * FROM Genus ORDER BY RelationGenus ASC"
    rsGenus.CursorType = 0
    rsGenus.CursorLocation = 2
    rsGenus.LockType = 1
    rsGenus.Open()
    
    rsGenus_numRows = 0
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <!-- Dynamic Dependent List box Code for *** VBScript *** Server Model //-->
    <script language="JavaScript">
    <!--
    
    var arrDynaList = new Array();
    var arrDL1 = new Array();
    
    arrDL1[1] = "order";               // Name of parent list box
    arrDL1[2] = "dbsearch";                  // Name of form containing parent list box
    arrDL1[3] = "family";               // Name of child list box
    arrDL1[4] = "dbsearch";                  // Name of form containing child list box
    arrDL1[5] = arrDynaList;
      
    <%
    Dim txtDynaListRelation, txtDynaListLabel, txtDynaListValue, oDynaListRS
    
    txtDynaListRelation = "Relation"      ' Name of recordset field relating to parent
    txtDynaListLabel = "Label"            ' Name of recordset field for child Item Label
    txtDynaListValue = "Value"            ' Name of recordset field for child Value
    Set oDynaListRS = rsFamily            ' Name of child list box recordset
      
    Dim varDynaList
    varDynaList = -1
    
    Dim varMaxWidth
    varMaxWidth = "1"
    
    Dim varCheckGroup
    varCheckGroup = oDynaListRS.Fields.Item(txtDynaListRelation).Value
    
    Dim varCheckLength
    varCheckLength = 0
    
    Dim varMaxLength
    varMaxLength = 0
    
    While (NOT oDynaListRS.EOF)
    
     If (varCheckGroup <> oDynaListRS.Fields.Item(txtDynaListRelation).Value) Then
      If (varCheckLength > varMaxLength) Then
       varMaxLength = varCheckLength
      End If
      varCheckLength = 0
     End If
    %>
     arrDynaList[<%=(varDynaList+1)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListRelation).Value)%>"
     arrDynaList[<%=(varDynaList+2)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListLabel).Value)%>"
     arrDynaList[<%=(varDynaList+3)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListValue).Value)%>"
    <%
     If (len(oDynaListRS.Fields.Item(txtDynaListLabel).Value) > len(varMaxWidth)) Then
      varMaxWidth = oDynaListRS.Fields.Item(txtDynaListLabel).Value
     End If
     varCheckLength = varCheckLength + 1
     varDynaList = varDynaList + 3
     oDynaListRS.MoveNext()
    Wend
    
    If (varCheckLength > varMaxLength) Then
     varMaxLength = varCheckLength
    End If
    %>
    
    //-->
    </script>
    
    <!-- End of object/array definitions, beginning of generic functions -->
    
      <!-- Dynamic Dependent List box Code for *** VBScript *** Server Model //-->
    <script language="JavaScript">
    
    var arrDynaList2 = new Array();
    var arrDL2 = new Array();
    
    arrDL2[1] = "family";               // Name of parent list box
    arrDL2[2] = "dbsearch";                  // Name of form containing parent list box
    arrDL2[3] = "genus";               // Name of child list box
    arrDL2[4] = "dbsearch";                  // Name of form containing child list box
    arrDL2[5] = arrDynaList2;
      
    <%
    Dim txtDynaListRelation2, txtDynaListLabel2, txtDynaListValue2, oDynaListRS2
    
    txtDynaListRelation2 = "RelationGenus"      ' Name of recordset field relating to parent
    txtDynaListLabel2 = "Label"            ' Name of recordset field for child Item Label
    txtDynaListValue2 = "Value"            ' Name of recordset field for child Value
    Set oDynaListRS2 = rsGenus             ' Name of child list box recordset
      
    Dim varDynaList2
    varDynaList2 = -1
    
    Dim varMaxWidth2
    varMaxWidth2 = "1"
    
    Dim varCheckGroup2
    varCheckGroup2 = oDynaListRS2.Fields.Item(txtDynaListRelation2).Value
    
    Dim varCheckLength2
    varCheckLength2 = 0
    
    Dim varMaxLength2
    varMaxLength2 = 0
    
    While (NOT oDynaListRS2.EOF)
    
     If (varCheckGroup2 <> oDynaListRS2.Fields.Item(txtDynaListRelation2).Value) Then
      If (varCheckLength2 > varMaxLength2) Then
       varMaxLength2 = varCheckLength2
      End If
      varCheckLength2 = 0
     End If
    %>
     arrDynaList2[<%=(varDynaList2+1)%>] = "<%=(oDynaListRS2.Fields.Item(txtDynaListRelation2).Value)%>"
     arrDynaList2[<%=(varDynaList2+2)%>] = "<%=(oDynaListRS2.Fields.Item(txtDynaListLabel2).Value)%>"
     arrDynaList2[<%=(varDynaList2+3)%>] = "<%=(oDynaListRS2.Fields.Item(txtDynaListValue2).Value)%>"
    <%
     If (len(oDynaListRS2.Fields.Item(txtDynaListLabel2).Value) > len(varMaxWidth2)) Then
      varMaxWidth2 = oDynaListRS2.Fields.Item(txtDynaListLabel2).Value
     End If
     varCheckLength2 = varCheckLength2 + 1
     varDynaList2 = varDynaList2 + 3
     oDynaListRS2.MoveNext()
    Wend
    
    If (varCheckLength2 > varMaxLength2) Then
     varMaxLength2 = varCheckLength2
    End If
    %>
    </script>
    
    <script language="JavaScript">
    <!--
    
    function setDynaList(arrDL){
    
     var oList1 = document.forms[arrDL[2]].elements[arrDL[1]];
     var oList2 = document.forms[arrDL[4]].elements[arrDL[3]];
     var arrList = arrDL[5];
     
     clearDynaList(oList2);
     
     if (oList1.selectedIndex == -1){
      oList1.selectedIndex = 0;
     }
    
     populateDynaList(oList2, oList1[oList1.selectedIndex].value, arrList);
     return true;
    }
     
    function clearDynaList(oList){
    
     for (var i = oList.options.length; i >= 0; i--){
      oList.options[i] = null;
     }
     
     oList.selectedIndex = -1;
    }
     
    function populateDynaList(oList, nIndex, aArray){
    
     for (var i = 0; i < aArray.length; i= i + 3){
      if (aArray[i] == nIndex){
       oList.options[oList.options.length] = new Option(aArray[i + 1], aArray[i + 2]);
      }
     }
    
     if (oList.options.length == 0){
      oList.options[oList.options.length] = new Option("[none available]",0);
     }
     
     oList.selectedIndex = 0;
    }
    
    //-->
      </script>
    </head>
    
    <body>
    <form action="index2.asp" method="get" name="dbsearch" id="dbsearch">
      <p>Order 
        <select name="order" id="order" onChange="setDynaList(arrDL1);setDynaList(arrDL2)">
          <%
    While (NOT rsOrder.EOF)
    %>
          <option value="<%=(rsOrder.Fields.Item("Relation").Value)%>"><%=(rsOrder.Fields.Item("Labels").Value)%></option>
          <%
      rsOrder.MoveNext()
    Wend
    If (rsOrder.CursorType > 0) Then
      rsOrder.MoveFirst
    Else
      rsOrder.Requery
    End If
    %>
        </select>
      </p>
      <p>Family
        <select name="family" id="family" >
    	<%
    Dim varLoopCounter
    For varLoopCounter = 1 TO varMaxLength
    %>
     <option value = "<%=varMaxWidth%>"><%=varMaxWidth%></option>
    <%
    Next
    %>
    
        </select>
      </p>
      <p>Genus 
        <select name="genus" id="genus">
        </select>
    </p>
    </form>
    </body>
    </html>
    <%
    rsOrder.Close()
    Set rsOrder = Nothing
    %>
    <%
    rsFamily.Close()
    Set rsFamily = Nothing
    %>
    <%
    rsGenus.Close()
    Set rsGenus = Nothing
    %>
    Any help would be appreciated.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    All i get is a blank page when i try to go to it. I can't see the error, i've defined all of my variables.
    The reason you don't see the error is a MS "Feature". In IE: Tools > Internet Options > Advanced, clear the "Show Friendly HTTP Error Messages" checkbox and the errors will start showing.

    Once you can see the errors, you've got a good start on fixing the problem.
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •