Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Highlght search term but ignore HTML markup

Highlght search term but ignore HTML markup

Highlght search term but ignore HTML markup

thread333-863709: text highlighter

I've been trying to implement the code in the above thread but I'm getting an error when trying to call it.
The error is "Wrong number of arguments or invalid property assignment: 'HighLight'"

The function I've copied is below


Function HighLight(TextIn, TextToHighlight, bAll)
dim i,WordArr,TextOut,bHL,bHL2,bNoHL

const HLStyle = "<span style=""color:red;font-weight:bold;background-color:#FFFFCC"">"
const HLStyle2 = "<span style=""color:blue;font-weight:bold;background-color:silver"">"

WordArr = Split(TextIn," ")
for i = 0 to Ubound(WordArr)
	bHL = False
	bHL2 = False
	if lcase(WordArr(i)) = "<a" then bNoHL = true
   if not bNoHL then
		if WordArr(i) = TextToHighlight then bHL = True ' highlight this word 
		if PunctMarks(right(WordArr(i),1),"[.,]") then    'check for full stop or comma
			if TextToHighlight = left(WordArr(i),len(WordArr(i))-1) then bHL = True
			' if word matches ignoring the last char highlight it
		end if
		if bAll then 
			' highlight all instances
			if InStr(WordArr(i),TextToHighlight) <> 0 then bHL2 = True
		end if
		if bHL then
			TextOut = TextOut & " " & HLStyle & WordArr(i) & "</span>"
		elseif bHL2 then
			TextOut = TextOut & " " & HLStyle2 & WordArr(i) & "</span>"
			TextOut = TextOut & " " &  WordArr(i)
		end if
	end if
		if lcase(WordArr(i)) = "</a>" then bNoHL = false

HighLight = TextOut
End Function

function PunctMarks(strIn, Pattern)
dim objRE
set objRE = New RegExp 
objRE.pattern = Pattern

PunctMarks = objRE.Test(strIn)

end function 

I am then calling it by using the below in my page


<%=HighLight("texttosearch", "text", true)%> 

Can anybody spot anything glaringly obvious??

RE: Highlght search term but ignore HTML markup

Looks ok to me; are you sure the error is occurring on the ASP line you indicated? And that the highlight function is in the same asp file, or included in that file?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close