Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/06/2013, 08:21
maialenlopez
 
Fecha de Ingreso: abril-2012
Mensajes: 449
Antigüedad: 12 años, 1 mes
Puntos: 7
Respuesta: Que con el evento onchange me carge un combobox

Ya lo he solucionado, he utilizado AJAX para ello.

Os dejo el código por si a alguien le sirve de ayuda.

referencias_revisiones.asp
Código ASP:
Ver original
  1. <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  2. <html>
  3.     <head>
  4.     <script language="javascript" type="text/javascript">
  5.     function nuevoAjax(){
  6.         /* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
  7.         lo que se puede copiar tal como esta aqui */
  8.         var xmlhttp=false;
  9.         try{
  10.            // Creacion del objeto AJAX para navegadores no IE
  11.            xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  12.         }
  13.         catch(e){
  14.            try{
  15.                // Creacion del objet AJAX para IE
  16.                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  17.            }
  18.            catch(E) { xmlhttp=false;
  19.            }
  20.         }
  21.         if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  22.             xmlhttp=new XMLHttpRequest();
  23.         }
  24.         return xmlhttp;
  25.     }
  26.  
  27.     function cargaAplicacion(){
  28.         //alert ("entra1");
  29.         var valor=document.getElementById("pedido").value;
  30.         //alert (valor);        
  31.        
  32.         if (valor==0){         
  33.            document.getElementById("celda_aplicacion").innerHTML=" Escribe un proyecto previamente";
  34.         }
  35.         else{
  36.             //alert ("entra2");
  37.             ajax=nuevoAjax();
  38.             ajax.open("GET", "careferencias.asp?pedido="+valor, true);
  39.             ajax.onreadystatechange=function(){
  40.                if (ajax.readyState==1){
  41.                    combo=document.getElementById("celda_aplicacion");
  42.                    combo.length=0;
  43.                    var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando...";
  44.                    combo.appendChild(nuevaOpcion);
  45.                    combo.disabled=false;      
  46.                }
  47.                if (ajax.readyState==4){
  48.                     //alert ("entra3");
  49.                    //alert(ajax.responseText);
  50.                    document.getElementById("celda_aplicacion").innerHTML=ajax.responseText;
  51.                }
  52.            }
  53.            ajax.send(null);
  54.         }
  55.     }
  56.     </script>
  57.  
  58.     </head>
  59.     <body>
  60.         <%
  61.         Set conn = Server.createobject("adodb.connection")
  62.         Set tablabase = Server.createobject("adodb.recordset")
  63.         conn.open "coplan"
  64.         %>
  65.         <table border="5">
  66.             <tr>
  67.                 <td>
  68.                     <form action="referencias_revisiones.asp" method = "post" id="form4" name="buscarPedido">
  69.                         <table border="2" align="center">
  70.                             <tr>
  71.                                 <td align="center" colspan="2">
  72.                                     <u><big><big><strong><tt>REFERENCIAS - REVISIONES</tt></strong></big></big></u>
  73.                                 </td>
  74.                             </tr>
  75.                             <tr>
  76.                                 <td>
  77.                                     Introduce proyecto:
  78.                                     <input type="text" name="pedido" id="pedido" size=20 value="" onchange="cargaAplicacion()">
  79.                                 </td>
  80.                                 <td id="celda_aplicacion">
  81.                                 </td>
  82.                             </tr>
  83.                         </table>
  84.                     </form>
  85.                 </td>
  86.             </tr>
  87.         </table>
  88.         <%Set tablabase = Nothing
  89.         Conn.Close
  90.         Set Conn = Nothing%>
  91.     </body>
  92. </html>

careferencias.asp
Código ASP:
Ver original
  1. <%
  2.     valor = Request("pedido")
  3.     'response.write valor
  4.    
  5.     'if len(valor)>3 then
  6.    
  7.     Set conn = Server.createobject("adodb.connection")
  8.     Set tablabase = Server.createobject("adodb.recordset")
  9.     conn.open "coplan"
  10.        
  11.        
  12.     tablabase.open "select distinct revision from r_coplan where pedido ='"&valor&"'", conn
  13.    
  14.     response.write "<select class=""combo"" id=""aplicacion"" name=""aplicacion""><option></option>"
  15.  
  16.     if tablabase.eof then
  17.         response.write "<option></option>"
  18.     else
  19.         do until tablabase.eof
  20.             response.Write "<option value=""" & tablabase("revision") & """>" & Server.HtmlEncode(tablabase("revision")) & "</option>"
  21.             tablabase.movenext
  22.         loop
  23.     end if
  24.     tablabase.close
  25.     set tablabase=nothing
  26.    
  27.     response.write "</select>"
  28. %>

__________________
Gracias por todo;

Un saludo