Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 02:09
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 448
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, 13:30
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 448
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

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