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 > highlighting. Problem simplified but still there

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-03-04, 17:16
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 448
highlighting. Problem simplified but still there

I'm using the code on:
http://www.aspfree.com/c/a/ASP%20Cod...-by-Meraj-Sami

I want to use two colors on two keywords, one in red, the second in blue.

This is the result:
http://n.1asphost.com/wheelofgod/highlighting.asp

(there is a third color with a third keyword but, never mind that)

The problem is that it's restarting the text once it has found and replaced the keyword in color.
Reply With Quote
  #2 (permalink)  
Old 10-04-04, 23:29
rokslide rokslide is offline
Coffee Minion
 
Join Date: Nov 2003
Location: Sydney
Posts: 1,515
well I tried to look at your page as an example but it failed so....
Reply With Quote
  #3 (permalink)  
Old 10-05-04, 00:31
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 448
yes the same happenned to me today. Strange.
Reply With Quote
  #4 (permalink)  
Old 10-05-04, 00:34
rokslide rokslide is offline
Coffee Minion
 
Join Date: Nov 2003
Location: Sydney
Posts: 1,515
assuming you are using the first version of the example you should be able to just do it multiple times to achieve what you want.
Reply With Quote
  #5 (permalink)  
Old 10-05-04, 00:42
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 448
here is the code:
Code:
<SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER"> Function stringReplace(strSearchWithin,strSearchFor,two,three) Dim lngStartingPosition Dim lngFoundPosition Dim lngFoundtwoPosition Dim lngFoundthreePosition Dim strReplaced 'Set the start position lngStartingPosition=1 lngFoundPosition=InStr(lngStartingPosition,strSearchWithin,strSearchFor,1) do while lngFoundPosition > 0 'found strReplaced=strReplaced & Mid(strSearchWithin,lngStartingPosition,lngFoundPosition-lngStartingPosition) & "<font color='red'>" & mid(strSearchWithin,lngFoundPosition,len(strSearchFor)) & "</font>" lngFoundPosition=lngFoundPosition+len(strSearchFor) lngFoundPosition=InStr(lngStartingPosition,strSearchWithin,strSearchFor,1) Loop stringReplace=strReplaced & Mid(strSearchWithin,lngStartingPosition) 'catch the last one 'Set the start position lngStartingPosition=1 lngFoundtwoPosition=InStr(lngStartingPosition,strSearchWithin,two,1) do while lngFoundtwoPosition > 0 'found strReplaced=strReplaced & Mid(strSearchWithin,lngStartingPosition,lngFoundtwoPosition-lngStartingPosition) & "<font color='blue'>" & mid(strSearchWithin,lngFoundtwoPosition,len(two)) & "</font>" lngStartingPosition=lngFoundtwoPosition+len(two) lngFoundtwoPosition=InStr(lngStartingPosition,strSearchWithin,two,1) Loop stringReplace=strReplaced & Mid(strSearchWithin,lngStartingPosition) 'catch the last one End Function </SCRIPT> <% OPTION EXPLICIT Dim strSearchWithin,strSearchFor,two,three strSearchWithin="Ezra 7:1 Now after these things, in the reign of Artaxerxes king of Persia, Ezra the son of Seraiah, the son of Azariah, the son of Hilkiah, " strSearchFor="Ezra" two="Artaxerxes" three="king" Response.Write stringReplace(strSearchWithin,strSearchFor,two,three) %><br><br> <font color='red'>ezra</font> <font color='blue'>artaxerxes</font> <br><br> Original phrase:<br> Ezra 7:1 Now after these things, in the reign of Artaxerxes king of Persia, Ezra the son of Seraiah, the son of Azariah, the son of Hilkiah, <br><br> The problem is that it's restarting the text once it has found and replaced the keyword in color.
Reply With Quote
  #6 (permalink)  
Old 10-05-04, 00:52
rokslide rokslide is offline
Coffee Minion
 
Join Date: Nov 2003
Location: Sydney
Posts: 1,515
in your second loop you should be using the new string not the orginal string... eg
Code:
<SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER"> Function stringReplace(strSearchWithin,strSearchFor,two,three) Dim lngStartingPosition Dim lngFoundPosition Dim lngFoundtwoPosition Dim lngFoundthreePosition Dim strReplaced 'Set the start position lngStartingPosition=1 lngFoundPosition=InStr(lngStartingPosition,strSearchWithin,strSearchFor,1) do while lngFoundPosition > 0 'found strReplaced=strReplaced & Mid(strSearchWithin,lngStartingPosition,lngFoundPo sition-lngStartingPosition) & "<font color='red'>" & mid(strSearchWithin,lngFoundPosition,len(strSearch For)) & "</font>" lngFoundPosition=lngFoundPosition+len(strSearchFor ) lngFoundPosition=InStr(lngStartingPosition,strSear chWithin,strSearchFor,1) Loop tmpString=strReplaced & Mid(strSearchWithin,lngStartingPosition) 'catch the last one strReplaced="" 'Set the start position lngStartingPosition=1 lngFoundtwoPosition=InStr(lngStartingPosition,tmpString,two,1) do while lngFoundtwoPosition > 0 'found strReplaced=strReplaced & Mid(tmpString,lngStartingPosition,lngFoundtw oPosition-lngStartingPosition) & "<font color='blue'>" & mid(tmpString,lngFoundtwoPosition,len(two)) & "</font>" lngStartingPosition=lngFoundtwoPosition+len(two) lngFoundtwoPosition=InStr(lngStartingPosition,tmpString,two,1) Loop stringReplace=strReplaced & Mid(tmpString,lngStartingPosition) 'catch the last one End Function
or something very similar.
Reply With Quote
  #7 (permalink)  
Old 10-05-04, 15:24
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 448
This thing is giving me a hard time:
Quote:
Active Server Pages error 'ASP 0113'

Script timed out

/wheelofgod/highlight2.asp

The maximum amount of time for a script to execute was exceeded. You can change this limit by specifying a new value for the property Server.ScriptTimeout or by changing the value in the IIS administration tools.
My search engine loads faster than the link posted above.
Reply With Quote
  #8 (permalink)  
Old 10-05-04, 20:40
rokslide rokslide is offline
Coffee Minion
 
Join Date: Nov 2003
Location: Sydney
Posts: 1,515
yeah, what are your querying and how big is your database? It looks like you are trying to do a big query and it's not returning in time or you have set up some kind of nasty looping somewhere or something.
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