Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

advanced search using ASP and Javascript

Status
Not open for further replies.

bexp

Technical User
Apr 30, 2003
2
0
0
GB
Can anyone advise on the script needed to do an advance search, ie giving the the user the choice of any word, all words, exact phase etc

All the ones I find use Vbscript with ASP, but I am using Ultradev and have my site to use javascript with asp.

The database is access 2000

Please advise, thanks.
 
you need a conditional module to check for the existence of certain search criteria and then build the SQL statement to run it based on that...


example

==>any word or any phrase:
WHERE strSearchCriteria LIKE '%strAny_Word_or_Phrase%'

==>exact word or phrase:
WHERE strSearchCriteria = 'strExact_Word_or_Phrase'

==>all words:
WHERE strSearchCriteria = 'strExact_Word_or_Phrase' OR strSearchCriteria = 'strExact_Word_or_Phrase'....etc.


 
Thanks for your replys

This is the vb / sql code which is generated - what I want is the equivlent in js

-----

<%
'VBScript version of Basic-UltraDev Dyamic Search SQL
'for Recordset1
Dim tfm_andor,tfm_exact
tfm_andor = &quot;AND&quot;
tfm_exact = &quot;false&quot;
'if any words option
'not implemented
'if exact phrase option
'not implemented
If Cstr(Request(&quot;search&quot;))<> &quot;&quot; Then
Dim tfm_SQLstr,tfm_searchField,tfm_databaseFields,bellChar
tfm_SQLstr = &quot; WHERE (&quot;
tfm_searchField = lcase(Request(&quot;search&quot;))
tfm_databaseFields = Split(&quot;Bands,Town&quot;,&quot;,&quot;)
bellChar = chr(7)
If InStr(tfm_searchField,chr(34)) Or tfm_exact = &quot;true&quot; Then
tfm_searchField = Replace(tfm_searchField,chr(34),&quot;&quot;)
tfm_andor = &quot;OR&quot;
ElseIf InStr(lcase(tfm_searchField),&quot; or &quot;) Then
tfm_searchField = Replace(tfm_searchField,&quot; or &quot;,bellChar)
tfm_andor = &quot;OR&quot;
ElseIf InStr(tfm_searchField,&quot;,&quot;) Or InStr(tfm_searchField,&quot; &quot;) Or InStr(lcase(tfm_searchField),&quot; and &quot;) Then
tfm_searchField = Replace(tfm_searchField,&quot; and &quot;,bellChar)
tfm_searchField = Replace(tfm_searchField,&quot;,&quot;,bellChar)
tfm_searchField = Replace(tfm_searchField,&quot; &quot;,bellChar)
End If
splitField = Split(tfm_searchField,bellChar)
For i = 0 to ubound(splitField)
For j = 0 to ubound(tfm_databaseFields)
tfm_SQLstr = tfm_SQLstr & &quot;(&quot; & tfm_databaseFields(j) & &quot; LIKE '%&quot; & Replace(splitField(i),&quot;'&quot;,&quot;''&quot;) & &quot;%')&quot;
If j < ubound(tfm_databaseFields) Then tfm_SQLstr = tfm_SQLstr & &quot; OR &quot;
Next
If i < ubound(splitField) Then tfm_SQLstr = tfm_SQLstr & &quot;) &quot; & tfm_andor & &quot; (&quot;
Next
tfm_SQLstr = tfm_SQLstr & &quot;)&quot;
Else
tfm_SQLstr = &quot;&quot;
End If
%>
<%
set Recordset1 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Recordset1.ActiveConnection = MM_punkoiuk_STRING
Recordset1.Source = &quot;SELECT * FROM gigdates&quot; + tfm_SQLstr +&quot;&quot;
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top