Hi,
Could use some help with this, as I'm a total newbie in asp.
I'm building an Intranet site and found a search script.
This is the html code:
HTML Code:
<HTML>
<BODY>
<FORM METHOD=POST ACTION="TextSearch.asp">
Enter text to search for:
<INPUT TYPE=TEXT NAME=SearchText>
<INPUT TYPE=SUBMIT VALUE="Zoek!">
</FORM>
</BODY>
</HTML>
Followed by this TextSearch.asp script:
Code:
<HTML><BODY>
<B>Search Results for <%=Request("SearchText")%></B><BR>
<%
Function SearchFolder(oFSO, oFolder, sSearch)
Dim bFound, oTS
bFound = False
For Each oFile in oFolder.Files
If oFile.Size > 0 Then
If Response.IsClientConnected Then
Set oTS = oFSO.OpenTextFile(oFile.Path,fsoForReading)
strFileContents = oTS.ReadAll
If InStr(1,strFileContents,sSearch,1) then
Response.Write "<LI><A HREF=""/" & oFile.Name & _
""">" & oFile.Name & "</A><BR>"
bFound = True
End If
oTS.Close
End If
End If
Next
' For Each oFile in oFolder.Files
' If Response.IsClientConnected then
' Set oTS = oFSO.OpenTextFile(oFile.Path,fsoForReading)
'
' strFileContents = oTS.ReadAll
'
' If InStr(1,strFileContents,sSearch,1) then
' Response.Write "<LI><A HREF=""/" & oFile.Name & _
' """>" & oFile.Name & "</A><BR>"
'
' bFound = True
' End If
'
' oTS.Close
' End If
' Next
For Each oSubFolder In oFolder.Subfolders
bFound = bFound Or SearchFolder(oFSO, oSubFolder, sSearch)
Next
SearchFolder = bFound
End Function
Const fsoForReading = 1
Dim strSearchText
strSearchText = Request("SearchText")
'Now, we want to search all of the files
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Dim objFolder
Set objFolder = objFSO.GetFolder(Server.MapPath("/"))
Dim objFile, objTextStream, strFileContents, bolFileFound
bolFileFound = SearchFolder(objFSO, objFolder, strSearchText)
if Not bolFileFound then Response.Write "Helaas.. niets gevonden"
Set objTextStream = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
</BODY></HTML>
Problem is that the search is performed in the wwwroot directory, but I want it to search on the network.
More specific, I have another script to display directories and can browse into those dirs.
The goal is to show this searchfield and button in left (menu) frame when mainframe is filled with directory listing.
(Other option is to show searchfield in mainframe)
Then when a search is requested, the searchscript should search in the directory displayed in mainframe.
I have no clue however how to do this.. so please, have a look at this.. and get my eternal thanks..
