Este es el codigo:
Formulario:
Código ASP:
Ver original
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <html> <head> <script src="clienthint.js"></script> </head> <body> <% 'this displays the value of the textbox after the form is submitted If trim(Request("txt1")) <> "" Then Response.Write "You entered:" Response.Write "<b>" & Request("txt1") & "</b><br /><br />" End If %> <form name="form1" action="clienthint.asp" method="post"> Buscar: <input type="text" name="txt1" id="txt1" onKeyUp="showHint(this.value,'txt1','form1',true)"> <input type="submit" name="submit" value="Enviar"> </form> <p>Sugerencias: <span id="txtHint"></span></p> </body> </html>
clienthint.js
Código PHP:
var xmlHttp
function showHint(str, box, thisForm, autoSubmit)
{
if (str.length==0)
{
document.getElementById("txtHint").innerHTML="";
return;
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="gethint.asp";
url=url+"?q="+str;
url=url+"&b="+box;
url=url+"&f="+thisForm;
url=url+"&a="+autoSubmit;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
//this function allows for Clickable suggestions
function setTextBox(thisText,thisBox,thisForm,autoSubmit){
document.getElementById(thisBox).value = thisText
//this autoSubmits the form after a suggestion is clicked - it is not working :(
//if(autoSubmit=='true'){
// alert(thisForm);
// document.getElementById(thisForm).submit();
//}
}
gethint.asp
Código ASP:
Ver original
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% response.expires=-1 Dim rsWords Dim rsWords_numRows Dim q Dim b Dim hint q=ucase(request.querystring("q")) b=(request.querystring("b")) f=(request.querystring("f")) a=(request.querystring("a")) hint="" Set rsWords = Server.CreateObject("ADODB.Recordset") rsWords.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db_hint_words.mdb") rsWords.Source = "SELECT * FROM TBL_WORDS WHERE (word LIKE'" + q + "%') ORDER BY WORD" rsWords.CursorType = 2 rsWords.CursorLocation = 2 rsWords.LockType = 3 rsWords.Open() rsWords_numRows = 0 If Not rsWords.EOF Then Do While Not rsWords.EOF 'response.write(rsWords.Source) If trim(hint) = "" Then hint = "<a href=""javascript:setTextBox('" & rsWords("word") & "','" & b & "','" & f & "','" & a & "');"">" & rsWords("word") & "</a>" Else hint = hint & " , <a href=""javascript:setTextBox('" & rsWords("word") & "','" & b & "','" & f & "','" & a & "');"">" & rsWords("word") & "</a>" End If rsWords.MoveNext() Loop End If if trim(hint)="" then response.write("No se han encontrado coincidencias") else response.write(hint) end if rsWords.Close() Set rsWords = Nothing %>
Bueno , lo que pasa es que los resultados los despliega hacia el lado y yo quiero que los despliegue hacia abajo como si fuera una lista desplegable me entienden?
Creo que lo que se debe modificar está en el último archivo, osea el que ejecuta la consulta a la base de datos y muestra los resultados, el gethint.asp
De antemano muchas gracias