| |
gilgalbiblewheel
Posts: 14
Score: 0
Joined: 4/6/2005
From:
Status: offline
|
[CODE] <% strFind = Keyword '"jeSus christ joseph begat" strText =rs("text_data") '"And Jacob begat Joseph the husband of Mary, of whom was born Jesus, who is called Christ." response.write Highlight(strText, strFind) %> <SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER"> Function Highlight(strText, strFind) '// Check that at least one search term has been submitted If Len(strFind) < 1 Then '// no search term entered. Exit the function Highlight = "No search term entered" Exit Function End If '// define the colours to be used to highlight search results Dim strColors : strColors = "#FF0000" ',#008000,#0000FF '// and split them into an array Dim arrColors : arrColors = Split(strColors,",") '// split the search terms into an array Dim arrFind : arrFind = Split(strFind," ") '// Initialize the regular expression object to perfom the search Dim oRegExp, oMatches, sMatch Set oRegExp = New RegExp oRegExp.Global = True '// returns all matches to the search term oRegExp.IgnoreCase = True '// Case insensitive '// loop through the array of search terms to find matches Dim i, strHighlight For i = 0 to UBound(arrFind) oRegExp.Pattern = arrFind(i) '// sets the search pattern string Set oMatches = oRegExp.Execute(strText) '// performs the search for each match in oMatches '// build the code to be used to highlight results strHighlight = "<font color='red'><b>" & match.value & "</b></font>" '" & arrColors(i) & " next '// then replace matches from the search with the above code strText = oRegExp.Replace(strText, strHighlight) Next '// release the RegExp object Set oRegExp = Nothing '// and return the result Highlight = strText End Function </SCRIPT> [/CODE] SO I made the changes but whenever I insert the Keyword and rs("text_data") I get this error: [QUOTE] Microsoft VBScript runtime error '800a01c2' Wrong number of arguments or invalid property assignment: 'Highlight' /wheelofgod/highlightingz.asp, line 4 [/QUOTE]
|
|