Ver Mensaje Individual
  #97 (permalink)  
Antiguo 27/08/2006, 13:12
Avatar de Saruman
Saruman
 
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 21 años
Puntos: 5
Arbol de elementos

Hola... esta función es para generar un árbol de elementos, ideal para la creación de menú con opciones infinitas. Espero les sirva.
pd. Este script es original de mi amigo Vaalegk (gracias )

Utilizacion:

call CrearArbol(0, "|","")

Resultado:
|categoria1
||categoira2
|categoria3
||categoria4
|||categoria5


Código:
 
function CrearArbol(byVal ParentId, byVal Prefijo, byVal Current)
  sSQL = "select * from tabña where parentid=" & ParentId
  set RS = Master.Execute(sSQL)
  if RS.bof=false and RS.eof=false then
   while not RS.eof
    tmp_id = RS("codigo")
    nombre_menu = ucase(RS("nombre"))
 
    cadena = vbtab & vbtab & Current & nombre_menu & vbcrlf
    response.Write(cadena)
 
    call CrearArbol(tmp_id, Prefijo, Current & Prefijo)
 
    RS.movenext
   wend
  end if
 end function
 
 call CrearArbol(0, "|","")
saludos
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.