ciao a tutti ho il codice postato(per non esagerare non l'ho postato tutto) ora il mio problema sta che dopo aver inserito la porola chiave nell'apposito campo o dopo aver selezionato i campi opzionali(non postati)per effettuare la ricerca sn costretto a cliccare sul pulsante "cerca", ma io vorrei che la ricerca venisse eseguita anche cliccando su "invio" della tastiera. cosa c'è ke va cambiato?
grazie anticipatamente.
potete dare un occhiata qui http://www.vacanzeinsicilia.net/ricerca/ricerca.asp
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.Recordset")
Set RS2 = Server.CreateObject("ADODB.Recordset")
err_ = 1
strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" & Server.Mappath("/mdb-database/****.mdb")
%>
<form name="form1" method="get" action="">
<INPUT size=31 name="search">
<INPUT name="trova" type="submit" id="trova" value="Cerca">
<%
if request("trova") = "Cerca" then
ricerca =replace (request.QUERYSTRING("search"),"'","''")
categoria = replace (request.QUERYSTRING("categoria"),"'","''")
comune = replace (request.QUERYSTRING("comune"),"'","''")
provincia = replace (request.QUERYSTRING("provincia"),"'","''")
' ************************************************** ************************************************** *******************
' STRINGA PER LA RICERCA
' ************************************************** ************************************************** *******************
if ricerca <> "" and categoria = "0" and comune = "0" and provincia = "0" then
stringhe=Split(ricerca," ")
for x=0 to Ubound(stringhe)
sql_stringhe=sql_stringhe&" azienda like '%"&stringhe(x)&"%' OR comune like '%"&stringhe(x)&"%' OR provincia like '%"&stringhe(x)&"%' OR categoria like '%"&stringhe(x)&"%' AND"
next
sql_ricerca = "select * from aziende where"&Left(sql_stringhe,Len(sql_stringhe)-4)
end if
if ricerca = "" AND categoria <> "0" then
sql_ricerca = "select * from aziende where categoria = '"&categoria&"'"
end if
if ricerca = "" AND comune <> "0" then
sql_ricerca = "select * from aziende where comune = '"&comune&"'"
end if
if ricerca = "" AND provincia <> "0" then
sql_ricerca = "select * from aziende where provincia = '"&provincia&"'"
end if
if ricerca = "" AND categoria <> "0" and comune <> "0" then
sql_ricerca = "select * from aziende where categoria = '"&categoria&"' and comune = '"&comune&"'"
end if
if ricerca = "" AND categoria <> "0" and provincia <> "0" then
sql_ricerca = "select * from aziende where categoria = '"&categoria&"' and provincia = '"&provincia&"'"
end if
if ricerca = "" AND comune <> "0" and categoria <> "0" then
sql_ricerca = "select * from aziende where comune = '"&comune&"' and categoria = '"&categoria&"'"
end if
if ricerca = "" AND comune <> "0" and provincia <> "0" then
sql_ricerca = "select * from aziende where comune = '"&comune&"' and provincia = '"&provincia&"'"
end if
if ricerca = "" AND provincia <> "0" and categoria <> "0" then
sql_ricerca = "select * from aziende where provincia = '"&provincia&"' and categoria = '"&categoria&"'"
end if
if ricerca = "" AND provincia <> "0" and comune <> "0" then
sql_ricerca = "select * from aziende where provincia = '"&provincia&"' and comune = '"&comune&"'"
end if
if ricerca <> "" and categoria <> "0" then
sql_ricerca = "select * from aziende where azienda (like '"&ricerca&"' or azienda like '"&ricerca&"%') and categoria = '"&categoria&"'"
end if
'serve per la ricerca libera derivante da un'altra pagina
if ricerca <> "" and categoria = "" and comune = "" and provincia = "" then
stringhe=Split(ricerca," ")
for x=0 to Ubound(stringhe)
sql_stringhe=sql_stringhe&" azienda like '%"&stringhe(x)&"%' OR comune like '%"&stringhe(x)&"%' OR provincia like '%"&stringhe(x)&"%' OR categoria like '%"&stringhe(x)&"%' AND"
next
sql_ricerca = "select * from aziende where"&Left(sql_stringhe,Len(sql_stringhe)-4)
end if
conn.open strConn
rs.open sql_ricerca,conn,3,3
if not rs.eof then
err_ = 0
trovati = rs.recordcount
%>