If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > how to highlight in three colours? have code but

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-02-04, 01:09
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
how to highlight in three colours? have code but

There is something wrong in this. I couldn't figure it out.

I have three: Keyword, Keywordb, Keywordc
I had inserted: strSearchFor, two, three (same function)

Code:
<SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER">
Function stringReplace(strSearchWithin,strSearchFor,two,three)
Dim lngStartingPosition
Dim lngFoundPosition
Dim strReplaced
'Set the start position
lngStartingPosition=1
lngFoundPosition=InStr(lngStartingPosition,strSearchWithin,strSearchFor,1)
lngFoundPosition=InStr(lngStartingPosition,strSearchWithin,two,1)
lngFoundPosition=InStr(lngStartingPosition,strSearchWithin,three,1)
do while lngFoundPosition > 0
'found
strReplaced=strReplaced & Mid(strSearchWithin,lngStartingPosition,lngFoundPosition-lngStartingPosition) & "<font color='red'>" & "<b>" & mid(strSearchWithin,lngFoundPosition,len(strSearchFor)) & "</b>" & "</font>"

strReplaced=strReplaced & Mid(strSearchWithin,lngStartingPosition,lngFoundPosition-lngStartingPosition) & "<font color='blue'>" & "<b>" & mid(strSearchWithin,lngFoundPosition,len(two)) & "</b>" & "</font>"

strReplaced=strReplaced & Mid(strSearchWithin,lngStartingPosition,lngFoundPosition-lngStartingPosition) & "<font color='green'>" & "<b>" & mid(strSearchWithin,lngFoundPosition,len(three)) & "</b>" & "</font>"


lngStartingPosition=lngFoundPosition+len(strSearchFor)
lngStartingPosition=lngFoundPosition+len(two)
lngStartingPosition=lngFoundPosition+len(three)


lngFoundPosition=InStr(lngStartingPosition,strSearchWithin,strSearchFor,1)
lngFoundPosition=InStr(lngStartingPosition,strSearchWithin,two,1)
lngFoundPosition=InStr(lngStartingPosition,strSearchWithin,three,1)
Loop
stringReplace=strReplaced & Mid(strSearchWithin,lngStartingPosition) 'catch the last one
End Function
</SCRIPT>

<%

strSearchWithin=RS("res_text_data")
strSearchFor=Keyword
two=Keywordb
three=Keywordc
Response.Write stringReplace(strSearchWithin,strSearchFor,two,three)
%>
Reply With Quote
  #2 (permalink)  
Old 10-02-04, 12:30
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
more

what I'm getting is a repetition of "res_text_data" three times after a word is highlighted:

Now after these things, in the reign of Artaxerxes king[u]Now after these things[u], in the reign of Artaxerxes king of PeNow after these things, in the reign of Artaxerxes king of Persia, Ezra the son of Seraiah, the son of Azariah, the son of Hilkiah,

I had forgotten to include the Dim in the previous posting:
Code:
<%Dim strSearchWithin,strSearchFor,two,three%>
It would also help to mention you that the three keywords are:
Ezra, Artaxerxes, king. So when you see those words there is a repetition of the text.

There is a confusion in the colors, for instance one which is supposed to be red is in blue...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On