SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old February 25th, 2003, 01:49 PM
JavaMon JavaMon is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 1 JavaMon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Highlight search keywords on HTML page

I have an ASP search function which, after typing the search term, searches HTML pages and creates a list of links.

The problem is that I do not know how to code so the search term is highlighted in red after the user clicks on the link to view the HTML page.

Any ideas?

Reply With Quote
  #2  
Old February 25th, 2003, 02:31 PM
RayHogan RayHogan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: NJ, USA
Posts: 11 RayHogan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

I have to speculate on how you will be searching HTML pages.

My best guess form your message is that you will be opening and reading the text of html files within your site, and looking for user supplied search words.

Assuming this is your plan, you will need to write a temporary version of your searched files out where the html of the searched pages is modified to contain extra tags around the user requested search terms.

Add to this that other people will be doing other searches at the same time and you will need to create multiple sets of "searched HTML pages", and not to mention that you will then have to delete the pages after the user is done, and you have a bit of a nightmare on your hands.

This capability is made easier by the build-in Search mechanism, and some ASP-like programming, but be advised, that this search mechanism is the a favorite hackers playground.

Another alternative is to read the text of your html messages and make a new, super page containing the actual text of the searched pages, but this depends on how far from your original vision you can stray.

Another way is to modify the HTML and temporarily store it into a database and the links would not actually be to an HTML file, but to the edited (link added) version of the HTML file stored in a database record.


Then again, I may have of mis-understood from the beginning, and your search is actually something else.

Ray Hogan

Reply With Quote
  #3  
Old February 27th, 2003, 10:11 PM
makman111 makman111 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Minneapolis, MN
Posts: 11 makman111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
What I have done is the past is uses css and some text logic. I just put this togther as an example, but I think it is about 95% of what you need.

Hope this helps

JM

Place this in the <head> of your results page
----------------------------------------------------------------------------

.higlight
{
background: 000099; // or whatever color you want to use
}

Place this code somewhere after you retrieve you recordset
----------------------------------------------------------------------------
'get your searched text and the keyword(s)
sMySearchedText = objRS("FAQAnswer")
sMyKeyWord = Request.Form("Keyword")

' you can tokenize this is you have to with
sKeyword() = split(sMyKeyWord, " ")

i = 1
Do

' check to see if the keyword in is the searched text, if so return the position (iIndex)
iIndex = Instr(1,sMySearchedText, sKeyword(i))
If iIndex > 0 then

iLength = Len(sKeyword(i))
' set sLeftTemp equal to all text up to the keyword
sLeftTemp = Left(sMySearchedText, iIndex - 1)

' set sRightTemp equal to all text past the keyword
sRightTemp = Mid(iIndex+ iLength + 1,sMySearchedText)

' change to keyword to be highlighted
sTemp = "<span class=""highlight"">" & sKeyword(i) & "</span>"

'Put it all back together
sMySearchedText = sLeftTemp & sTemp & sRightTemp

End If

i = i + 1
Loop

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Highlight search keywords on HTML page


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway