<form action="referencias.asp" method = "post" id="form3" name="borrar">
<table border="1">
<%if request.queryString("eliminarHijo")<>"" then
Dim valorEliminarHijo
valorEliminarHijo = request.queryString("eliminarHijo")%>
<tr>
<td colspan="3" align="center">
<u><big><big><strong><tt>PROYECTO: <%response.write valorEliminarHijo%></tt></strong></big></big></u>
</td>
</tr>
tablabase.open "select count(n_pedido) as n_pedido from tablabase where n_pedido ='"&valorEliminarHijo&"'", conn%>
<%while not (tablabase.eof)%>
<%Dim existe_valorEliminarHijo
Session(tablabase("n_pedido")) = tablabase("n_pedido").value
existe_valorEliminarHijo = tablabase("n_pedido")%>
<%tablabase.moveNext%>
<%wend%>
<%tablabase.Close%>
<%if existe_valorEliminarHijo = "1" then%>
<%tablabase.open "select id as id from tablabase where n_pedido ='"&valorEliminarHijo&"'", conn%>
<%while not (tablabase.eof)%>
<%Dim id_pedido_valorEliminarHijo
Session(tablabase("id")) = tablabase("id").value
id_pedido_valorEliminarHijo = tablabase("id")%>
<%tablabase.moveNext%>
<%wend%>
<%tablabase.Close%>
<%if id_pedido_valorEliminarHijo<> "" then%>
<%tablabase.open "select id_pedidoHijo,n_pedido from referencias where id_pedidoPadre = '"&id_pedido_valorEliminarHijo&"%' order by id_pedidoHijo", conn%>
<%while not (tablabase.eof)%>
<tr align="left">
<%Session(tablabase("id_pedidoHijo")) = tablabase("id_pedidoHijo").value
Session(tablabase("n_pedido")) = tablabase("n_pedido").value
Redim Preserve pedidos(z)
pedidos(z) = tablabase("n_pedido").value
check = cstr(tablabase("id_pedidoHijo").value)%>
<td align="center">
<input type="checkbox" name="ch" value="<%=check%>">
</td>
<td align="left">
<%response.write pedidos(z)%>
</td>
<%i = i + 1
z= z + 1
tablabase.moveNext%>
</tr>
<%wend%>
<%tablabase.Close%>
<input type="hidden" name="valortext2" id="valortext2" value ="<%=valorEliminarHijo%>" />
<%end if%>
<%else%>
<tr>
<%response.write "* El proyecto introducido no existe"%>
</tr>
<%end if%>
<%end if%>
<%if request.Form("valortext2")<>"" then %>
<%valortext = request.Form("valortext2")%>
<%end if%>
<%If valortext_dondeAgregar <> "" then%>
<tr>
<td colspan="3" align="center">
<u><big><big><strong><tt>PROYECTO: <%response.write valortext_dondeAgregar%></tt></strong></big></big></u>
</td>
</tr>
tablabase.open "select count(n_pedido) as n_pedido from tablabase where n_pedido ='"&valortext_dondeAgregar&"'", conn%>
<%while not (tablabase.eof)%>
<%Dim existe5
Session(tablabase("n_pedido")) = tablabase("n_pedido").value
existe5 = tablabase("n_pedido")%>
<%tablabase.moveNext%>
<%wend%>
<%tablabase.Close%>
<%if existe5 = "1" then%>
<%tablabase.open "select id as id from tablabase where n_pedido ='"&valortext_dondeAgregar&"'", conn%>
<%while not (tablabase.eof)%>
<%Dim id_pedido5
Session(tablabase("id")) = tablabase("id").value
id_pedido5 = tablabase("id")%>
<%tablabase.moveNext%>
<%wend%>
<%tablabase.Close%>
<%if id_pedido5<> "" then%>
<%tablabase.open "select id_pedidoHijo,n_pedido from referencias where id_pedidoPadre = '"&id_pedido5&"%' order by id_pedidoHijo", conn%>
<%while not (tablabase.eof)%>
<tr align="left">
<%Session(tablabase("id_pedidoHijo")) = tablabase("id_pedidoHijo").value
Session(tablabase("n_pedido")) = tablabase("n_pedido").value
Redim Preserve pedidos(z)
pedidos(z) = tablabase("n_pedido").value
check = cstr(tablabase("id_pedidoHijo").value) %>
<td align="center">
<input type="checkbox" name="ch" value ="<%=check%>">
</td>
<td align="left">
<%response.write pedidos(z)%>
</td>
<%i = i + 1
z= z + 1
tablabase.moveNext%>
</tr>
<%wend%>
<%tablabase.Close%>
<input type="hidden" name="valortext2" id="valortext2" value ="<%=valortext_dondeAgregar%>"/>
<%end if%>
<%else%>
<tr>
<%response.write "*El proyecto introducido no existe" %>
</tr>
<%end if%>
<%end If%>
</table>
<table align="right">
<tr>
<td>
<input type="submit" name="eliminar" value="Eliminar">
<%if Request.Form("ch").Count then%>
<%For i = 1 To Request.Form("ch").Count%>
<%Dim seleccionados
seleccionados = Request.Form("ch")(i)%>
<%tablabase.open "delete from referencias where id_pedidoHijo ='"&seleccionados&"'", conn%>
<%Next%>
<%end if%>
<%if Request.Form("valortext2") <> "" then%>
<%Dim valortext2
valortext2 = request.Form("valortext2")
<%Response.Redirect "referencias.asp?eliminarHijo="&valortext2%>
<%end if%>
</td>
</tr>
</table>
</form>