Search HouseOfScripts.com

 

All Scripts        JavaScripts        ASP Scripts        Other Scripts

 

  Creating a Search Page For Multiple Directories on Your Web asp, send, email, cdonts, link, recordset, hyper, hyperlink, create, list, box, dependant, dynamic

If you want to search multiple directories on you Web, first of all you need to create files for as it says in Creating a Search Page For One Directory on Your Web. After that you need to make some changes in searchfiles.asp. As you can see, there are 2 parts in that file:

1.

<%
SearchTerm = request.form("term")
Novalid=" a b c d e f g h i j k l m n o p q r s t u v w x y z yes no and more"
NovalidResponse ="Go back and try again. Your search term is very common"

if instr(SearchTerm,Novalid)=0 then

Response. Write ("<CENTER><H2>Search results</H2></CENTER>")

FolderName= "FolderName"
ShowList()

else
Response.Write NovalidResponse
End if

SearchResponse=""
%>

2.

<%
Sub ShowList()
FolderToCheck = server.mappath("\") &"/" & FolderName & "/"
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(FolderToCheck)
Set fc = f.Files
For Each f1 in fc

Wfile = f1.name
if right(Wfile, 5)=".html" OR right(Wfile, 4)=".htm" then
Wfile2 = FolderToCheck & Wfile
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile(Wfile2)
ct = a.ReadAll
a.close
ct2=lcase(ct)
SearchTerm2 = lcase(SearchTerm)

if instr(ct2,SearchTerm2)>0 then

if instr(ct,"</title>")>0 then
longitud=instr(ct,"</title>")
longitud=longitud -1
ct=left(ct,longitud)
longitud2=len(ct)
longitud=instr(ct,"<title>")
longitud=longitud2 -longitud -6
ct=right(ct,longitud)
else
if instr(ct,"</TITLE>")>0 then
longitud=instr(ct,"</TITLE>")
longitud=longitud -1
ct=left(ct,longitud)
longitud2=len(ct)
longitud=instr(ct,"<TITLE>")
longitud=longitud2 -longitud -6
ct=right(ct,longitud)
end if
end if

SearchResponse= SearchResponse +"<TR><TD>"+ ct + "</TD><TD ALIGN=CENTER VALIGN=MIDDLE>" + " <A HREF=" + "/" + FolderName + "/" + Wfile +"> More </A></TD></TR>"
longitud=0
ct=""

end if
end if

Next

Response.Write ("<HTML><HEAD>
<TITLE>Search results</TITLE>
</HEAD>
<BODY BGCOLOR=FFFFFF><CENTER>")

Response.Write ("<TABLE BORDER=0 WIDTH=550><TR><TD BGCOLOR=C0C0C0><FONT SIZE=5><B>Search Results</B></FONT></TD></TR></TABLE>")

Response.Write ("<TABLE BORDER=0 WIDTH=550>")
if SearchResponse<>"" then
Response.Write SearchResponse
else
Response.Write ("<TR><TD>The specified term or phrase was not found</TD></TR>")
end if
Response.Write ("</TABLE>")

Response.Write ("<TABLE BORDER=0 WIDTH=550><TR>
<TD BGCOLOR=C0C0C0 ALIGN=RIGHT><FONT SIZE=1>Search utility provided by <A HREF=http://www.asptutorial.info>AspTutorial.info</A>
</FONT></TD></TR></TABLE>")

Response.Write ("</CENTER></BODY></HTML>")

End Sub
%>

I highlighted with blue places that you have to change.
"FolderName" change to FolderName2
"ShowList" change to ShowList2

After you replaced it and change the directory you want to search, it will search through 2 directories. If you want, you can make some changes so it will look better. You can click here and see an example of the code that will search through 3 directories and it will look good. If you need more, just change middle part and it will do.

 

 


Home       Scripts       Active WebTools       Web Templates       Forum       Tools        Hosting       Questions/Comments       Add/Request