Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2004, 07:13 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default How to highlight 3 keywords in 3 colors?

I found this. The reason I chose this is because it is case-sensitive. I changed to my preferences. This is working:

Code:
<SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER">
Function Highlight(strText, strFind, strBefore, strAfter)
  Dim nPos
  Dim nLen
  Dim nLenAll

  nLen = Len(strFind)
  nLenAll = nLen + Len(strBefore) + Len(strAfter) + 1

  Highlight = strText

  If nLen > 0 And Len(Highlight) > 0 Then
    nPos = InStr(1, Highlight, strFind, 1)
    Do While nPos > 0
      Highlight = Left(Highlight, nPos - 1) & _
        strBefore & Mid(Highlight, nPos, nLen) & strAfter &_
         Mid(Highlight, nPos + nLen)

      nPos = InStr(nPos + nLenAll, Highlight, strFind, 1)
    Loop
  End If
End Function
</SCRIPT>
<%
'OPTION EXPLICIT
Dim strText, strFind
strFind=Keyword
strText=RS("text_data")
strText= Highlight(strText, strFind,"<b>", "</b>")
'strFind=Keywordb
'strText=RS("text_data")
'strText= Highlight(strText, strFind,"<b>", "</b>")
'strFind=Keywordc
'strText=RS("text_data")
'strText= Highlight(strText, strFind,"<b>", "</b>")
Response.Write strText
%>
But I put "'" at the end like 'strFind=Keywordb. What I need is to highlight Keyword in red as it does already, Keywordb in blue, and Keywordc in green.

 
Old October 20th, 2004, 11:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

How about this?
Code:
strFind=Keyword
strText=RS("text_data")
strText= Highlight(strText, strFind,"<b>", "</b>")
strFind=Keywordb
strText= Highlight(strText, strFind,"<b>", "</b>")
strFind=Keywordc
strText= Highlight(strText, strFind,"<b>", "</b>")
Response.Write strText
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 20th, 2004, 06:01 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

thanks a lot!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Keywords on .CSS ? AMB CSS Cascading Style Sheets 1 May 27th, 2006 09:15 PM
use of Not and IS Nothing keywords jay schumacher VB.NET 2002/2003 Basics 1 March 31st, 2006 10:01 PM
highlight search keywords allang JSP Basics 2 October 13th, 2004 01:09 AM
META KEYWORDS anshul HTML Code Clinic 6 September 11th, 2004 06:06 PM
Excluding items with certain keywords ashcarrot SQL Language 4 July 23rd, 2003 10:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.