#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Minneapolis, MN
    Posts
    11
    Rep Power
    0

    XML based dynamic dropdown menus in ASP


    I am trying to create an XML based set of nested drop down menus. Essentially you would have three (or n) menus (i.e. Make, model, year). Each menu is dependent on the value of the previous box to populate itself and is dynamically updated via JavaScript when its parent box is changed.

    I know how to do this with JavaScript arrays, but populating the arrays in ASP from an SQL server can take some time, and the data is static within a 24 hour period. My idea is to have a XML doc stored on the server that the client can reference in the JavaScript routine and build the arrays on the client side w/o slowing the bogging down the page rendering with a SQL process.

    Any help would be appreciated.

    Thanks

    JM

    p.s.

    here is how I am currently doing it with ASP rendering inside of JavaScript.

    <% iIDC = 1 %>
    <% Do While Not rsIDCGet.EOF %>

    laIDC[<%=iIDC%>] = new IDC();
    laIDC[<%=iIDC%>].myName = "<%=rsIDCGet("IDC")%>";
    laIDC[<%=iIDC%>].LongValue = <%=rsIDCGet("IDCID")%>;
    laIDC[<%=iIDC%>].Cust = new Array();

    laIDC[<%=iIDC%>].Cust[0] = new Cust();
    laIDC[<%=iIDC%>].Cust[0].myName = "Select a Customer";
    laIDC[<%=iIDC%>].Cust[0].LongValue = -1;
    laIDC[<%=iIDC%>].Cust[0].TmpHost = new Array('Select a Host');
    <%
    ComDBA.ParameterClear
    ComDBA.Parameter 1, Session("LEID")
    ComDBA.Parameter 2, Session("UserID")
    ComDBA.Parameter 3, rsIDCGet("IDCID")

    Set rsCustsGet = ComDBA.ExecProc("usp_mss_Customers_Get")

    If ComDBA.ReturnCode <> 0 Then
    Response.Write(ComDBA.ErrorDesc)
    End If
    %>
    laIDC[<%=iIDC%>].Cust[1] = new Cust();
    laIDC[<%=iIDC%>].Cust[1].myName = "All Customers";
    laIDC[<%=iIDC%>].Cust[1].LongValue = 0;
    laIDC[<%=iIDC%>].Cust[1].TmpHost = new Array('Select a Host','All Hosts');

    <% iCust=2 %>
    <% Do While Not rsCustsGet.EOF %>

    laIDC[<%=iIDC%>].Cust[<%=iCust%>] = new Cust();
    laIDC[<%=iIDC%>].Cust[<%=iCust%>].myName = "<%=Replace(rsCustsGet("CustName"),vbCrLf,"")%>";
    laIDC[<%=iIDC%>].Cust[<%=iCust%>].LongValue = <%=rsCustsGet("CustID")%>;
    <%

    ComDBA.ParameterClear
    ComDBA.Parameter 1, rsCustsGet("CustID")
    ComDBA.Parameter 2, Session("UserID")

    Set rsHostNamesGet = ComDBA.ExecProc("usp_mss_HostNames_Get")

    If ComDBA.ReturnCode <> 0 Then
    Response.Write(ComDBA.ErrorDesc)
    End If

    sHosts = "'Select a Host','All Hosts'"
    Do While Not rsHostNamesGet.EOF
    sHosts = sHosts & ",'" & rsHostNamesGet("HostName") & "'"
    rsHostNamesGet.MoveNext
    Loop
    %>
    laIDC[<%=iIDC%>].Cust[<%=iCust%>].TmpHost = new Array(<%=sHosts%>);

    <% rsCustsGet.MoveNext() %>
    <% iCust = iCust + 1 %>
    <% Loop %>

    <% rsIDCGet.MoveNext() %>
    <% iIDC = iIDC + 1 %>
    <% Loop %>
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    8
    Rep Power
    0
    An ADO Recordset object has an open method that can take an XML file as a parameter and parse it into a recordset. So you could have a SQL Server job that saved the XML file to the server, and use ADO within your ASP to get the values from the file.

IMN logo majestic logo threadwatch logo seochat tools logo