Highlight search results but skip HTML tags

Results 1 to 2 of 2

Thread: Highlight search results but skip HTML tags

  1. #1
    Join Date
    Dec 1969

    Default Highlight search results but skip HTML tags

    hi, I&#039;m having trouble with a database search script I have. I want it to highlight the matching search results (i.e. if the user searches for the word "font" in the results, the word "font" is highlighted). I have this working, however I want my code to skip the HTML tags. right now my code looks like this: <BR><BR>&#039;words&#039; is the array of keywords used to search <BR>______________________________________________ _______ <BR><BR>Function highlightQuery(searchResult) <BR><BR>Dim searchQueryLength, startPosition, querySectionToReplace, highlightQueryTemp, SearchWordsCount <BR><BR>highlightQueryTemp = searchResult <BR><BR>SearchWordsCount = Ubound(words) <BR>For c=0 to SearchWordsCount <BR>searchQueryLength = Len(words(c)) <BR>startPosition = Instr(1,highlightQueryTemp,words(c),1) <BR>If startPosition &#062;= 1 then <BR>querySectionToReplace = Mid(highlightQueryTemp,startPosition,searchQueryLe ngth) <BR>highlightQueryTemp = Replace(highlightQueryTemp,querySectionToReplace," &#060;FONT style=""BACKGROUND-COLOR: #D3E3FA; text-decoration: underline"" color=#19488E &#062;" & querySectionToReplace & "&#060;/font&#062;",1) <BR>End If <BR>Next <BR>highlightQuery = highlightQueryTemp <BR><BR>End Function <BR>______________________________________________ _______ <BR><BR>but if some of the results contain HTML tags, sometimes the attributes in the tags are highlighted as "results". I want the script to skip whatever is in between &#060; and &#062; <BR><BR>I don&#039;t even know where to start. Any help is appreciated. THANK YOU!!

  2. #2
    Join Date
    Dec 1969

    Default Multiple crosspost, been answered<eop>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts