Simple Page Search

F

Fred Yarbrough

We have a simple html page that contains a long list of documents that users
can hyperlink to. The entries are currently in alphabetical order and we
would like to implement some type of page search instead of requiring users
to go to Edit, Find, and type in the search. I am very new to ASP but
suspect that this is possible. We would simply like to have a SEARCH box at
the top of the page and it allows users to search only the current page for
words. We simply want something a little more eloquent than the built in IE
page search. Any ideas are appreciated.

Thanks,
Fred
 
A

Aaron Bertrand - MVP

You want them to be able to search on a page that has already loaded on the
client? Then you want JavaScript, not ASP. ASP no longer exists once the
page is rendered on the client, so can't be a vehicle for client-side
activity.

If you store the document links in a database, you could search against a
database, but this is no more convenient than edit/find because you have to
go back to the server for that.
 
F

Fred Yarbrough

Aaron,
I thought that this could be saved as an ASP page and then scripted to
check upon submission of the Search button to see if the option was
populated. If so then it would return some filtered result set of links.
If they did not search then they would simply see all of the links and could
pick one.

I will look into the JavaScript option. I am really clueless with the
Java stuff but I will see what is out there.

Thanks Aaron,!

Fred
 
R

Rob Greene

You could use ASP code like this below, where you create the table entries
based on an array of data, filtered by the user's search parameters. In
this case, the page starts showing all entries. If the user entires
something like "F" to search, only those entries with an "F" are displayed.
-rwg

<%
dim Words, Links, Idx, SearchAction

Words = array( "First Listing", "Second Listing", "Third not First " )
Links = array( "www.microsoft.com", "support.microsoft.com",
"msdn.microsoft.com" )
SearchAction = Request.form( "SearchData" )
if SearchAction <> "" then
SearchAction = trim( SearchAction )
end if

%>


<HTML>
<Form method="POST" name="MyForm" >
<TABlE ALIGN="CENTER" border=1>

<TR>
<TD>Search:</TD>
<TD><INPUT TYPE="TEXT" NAME="SearchData">
</TD>
<TD><INPUT TYPE="SUBMIT" value="Search" name="SearchIt"> </TD>

<%

for Idx = 0 to UBound( Words ) step 1
if SearchAction = "" or Instr( 1, Words(Idx), SearchAction,
vbTextCompare ) <> 0 then
Response.write( "<TR><TD>" & Words(Idx) & "</TD><TD>" & Links(Idx) &
"</TD><TR>" )
end if
next

%>
</TABLE>
</FORM>
</HTML>
</BODY>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,145
Messages
2,570,824
Members
47,369
Latest member
FTMZ

Latest Threads

Top