dynamic ul with sub-levels

Posted by Y.G.J on Stack Overflow See other posts from Stack Overflow or by Y.G.J
Published on 2010-03-25T15:34:30Z Indexed on 2010/03/25 16:53 UTC
Read the original article Hit count: 401

Filed under:
|
|

i have this recursive code

<ul>
<%
sql="SELECT * FROM cats ORDER BY orderid " 
rs.Open sql,Conn
dim recArray
If Not rs.EOF Then
    recArray = rs.getRows()
    dim i
    for i=0 to uBound(recArray,2)
        if recArray(1,i)=0 then 
            call showMessage(i) 
        end if
    next

End If

function showMessage(index)
    %><li><%=recArray(2,index)%></li><%
    for a=0 to uBound(recArray,2)
        if recArray(1,a) = recArray(0,index) Then 
            %><ul><%
            call showMessage(a)
            %></ul><%
        end if
    next
    %></li><%
end function
%>
</ul>

inside the loop in the function i have the for the sub(s) but after each line of li it will close the ul how can i have that dynamic and to have the output like this

<ul>
  <li></li>
  <li></li>
  <li>
    <ul>
      <li></li>
      <li></li>
      <li></li>
    </ul>
  </li>
  <li></li>
</ul>

and not like this

<ul>
  <li></li>
  <li></li>
  <li>
    <ul><li></li></ul>
    <ul><li></li></ul>
    <ul><li></li></ul>
  </li>
  <li></li>
</ul>

© Stack Overflow or respective owner

Related posts about html

Related posts about vb.net