Ver Mensaje Individual
Antiguo 27-ago-2006, 13:12   #97 (permalink)
Saruman
Saruman está en el buen camino
 
Avatar de Saruman
 
Fecha de Ingreso: mayo-2003
Ubicación: Panamá
Mensajes: 1.154
Enviar un mensaje por MSN a Saruman Enviar un mensaje por Yahoo  a Saruman
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.
Saruman está desconectado   Responder Citando