Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/11/2012, 13:42
bellacord2
 
Fecha de Ingreso: septiembre-2009
Mensajes: 97
Antigüedad: 14 años, 7 meses
Puntos: 0
autocompletar

Saludos...tengo una pequena rutina creada en ajax, la cual se conecta a una pagina asp que trae los datos desde la db...

el archivo .js que hace la llamada a los campos a completar trabaja bien, o sea, trae los campos segun la tecla marcada...el problema es que me permite seleccionar xVariable de las mostradas...

Este es el archivo .js completo

Código:
var XMLHTTP=false;

function BuscarVariables(strTipo,strValorABuscar)
{ 
	var strURL = "../../herramientas/ajax.asp?id=" + strTipo + "&desc=" + strValorABuscar;
	//var strURL="findStateRegion.php?country="+countryid+"&region="+regionid+"&state="+stateid;


 	if (window.XMLHttpRequest)
		{// IE7+, Firefox, Chrome, Opera, Safari
		XMLHTTP = new XMLHttpRequest();
		}
	else
		{// IE6, IE5
		XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
		}
	
	if (XMLHTTP) 
		{
		 XMLHTTP.open("POST", strURL, true);
		 XMLHTTP.onreadystatechange = Resultados;
		 XMLHTTP.send(null);
		}
}

function Resultados(strTipo)
{
	if (XMLHTTP.readyState==4 )
	//if (XMLHTTP.readyState==4 && xmlhttp.status ==200)//0= peticion no iniciada, 1= conex al server, 2= solicitud recibida, 3=procesando, 4= peticion finalizada y resp esta lista
	
		{
			document.getElementById("autocomplete-jquery-aBox").innerHTML=XMLHTTP.responseText;
		}//responseText = valor que genera el servidor
}
y este es parte del asp que hace la conexion a la db

Código:

<%
	Dim Resultados
	Dim Registro
	Dim Empresa
	Dim strBuffer
	Dim strDonde
	Dim strPrefijo 
	Dim strTabla
	Dim strClaveTexto 
	
	strDonde=""
	strTabla=""
	strClaveTexto="0"
	
	Set Empresa = gVisita.Usuarios.Usuario(Session("Usr")).Empresas.Empresa(Session("CodEmpresa"))
	
	Select case Request("id")
		case "1"
			strPrefijo="CTA"
			strTabla="CON_CUENTAS"
			strClaveTexto="0"
		case "2"
			strPrefijo="CLS"
			strTabla="CTT_ENTIDADES_GRUPOS_CLASIFICACIONES"
			strClaveTexto="0"
		
	end select

	if strTabla <> "" and Request("desc") <> "" then
		strBuffer="<div>"
		Empresa.TablaGenerica = strPrefijo & ";" & strTabla & ";" & strClaveTexto
		''strDonde = strPrefijo & "_CODIGO like '%" & Request("desc") & "%'" 	
		strDonde = strPrefijo & "_DESCRIPCION like '%" & Request("desc") & "%'" 	
		
		Set Resultados = Empresa.BasListarTabla(strDonde)
	
		for each Registro in Resultados
			strBuffer = strBuffer & Registro.Codigo & "<br>"
			''strBuffer = strBuffer & Registro.Descripcion & "<br>"
		next
		strBuffer = strBuffer & "</div>"
		Response.Write(strBuffer)
	end if

%>
lo que necesito es poder tomar la variable del dropmenu q me presenta el inputtext

En mi form tengo algo mas o menos asi...
Código:


<tr height="25">
              <td valign="top">Motivo</td>
              <td ><input name="txtDescripcion" type="text" size="100" maxlength="255" value="<%=strDescripcion%>"></td>
            </tr>
            <tr height="25">
              <td valign="top">Fecha</td>
              <td >
              	<input name="txtFecha" type="text" size="10" value="<%=strFecha%>" onClick="popUpCalendar(this, Listado.txtFecha, 'dd/mm/yyyy');">
              </td>
            </tr>
          </table>
        <table id="asientos" width="95%" border="0" cellspacing="0" cellpadding="0" class="zebra" align="center">
        	<thead>
            <tr height="30">
                <th width="1%">&nbsp;</td>
                <th width="9%">Cuenta</td>
                <th width="15%"><a href="entidades.asp?te=Auxiliares&idc=<%=Request("id")%>"><font color='blue'>Auxiliar</font></a></td>
                <th width="15%"><a href="centros.asp?idc=<%=Request("id")%>"><font color='blue'>Centro de costo</font></a></td>
                <th width="40%">Motivo</td>
                <th width="10%">DEBE</td>
                <th width="10%">HABER</td>
            </tr>
            </thead>
            <tr height="30">
                <td>&nbsp;</td>
                <td><input type="text" size="12" name="txtCuenta" value="" onKeyUp="BuscarVariables(1,this.value);"><div id="autocomplete-jquery-aBox1"></div></td>
                <td><input type="text" size="25" name="txtEntidad" value="" onKeyUp="BuscarVariables(2,this.value);"><div id="autocomplete-jquery-aBox2"></div></td>
                <td><input type="text" size="25" name="txtCentroCosto" value="" onKeyUp="BuscarVariables(3,this.value);"><div id="autocomplete-jquery-aBox"></div></td>
                <td><input type="text" size="79" name="txtMotivo" value=""></td>
                <td><input type="text" size="14" name="txtDebe" style="text-align:right" value="<%=FormatearNro(0)%>" align="right"></td>
                <td><input type="text" size="14" name="txtHaber" style="text-align:right" value="<%=FormatearNro(0)%>" align="right"></td>
            </tr>

lo que no se es como llamar al declarar la funcion js par que me traiga los valores en una lista