Allora, la funzione non la modificare!
A questa pagina va passata via FORM con metodo POST l'ID della voce da eliminare. La funzione a quel punto elimina tutti figli, nipoti e pronipoti da quel livello in giù.
codice:
<%
function deleteChilds(cn,valueID)
loopFunction = false
s = "SELECT IDMenu FROM Menu WHERE IDPadre = " & valueID
set r = cn.execute(s)
if not r.eof then
tempID = ""
loopFunction = true
do until r.eof
tempID = tempID & r("IDMenu") &","
r.moveNext
loop
end if
r.close
set r = nothing
cn.execute("DELETE * FROM Menu WHERE IDMenu = " & valueID)
if loopFunction then
tempID = left(tempID,len(tempID)-1)
tempID = split(tempID,",")
for i = 0 to uBound(tempID)
deleteChilds cn, tempID(i)
next
end if
end function
id = request.form("id")
set conn = server.createObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath(("../Db/db_sinergico.mdb")
if len(id) > 0 and isNumeric(id) then deleteChilds conn, id
conn.close
set conn = nothing
%>