| |
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.
|
 |

10-03-04, 17:16
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 448
|
|
|
highlighting. Problem simplified but still there
|

10-04-04, 23:29
|
|
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....
|
|

10-05-04, 00:31
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 448
|
|
|
yes the same happenned to me today. Strange.
|
|

10-05-04, 00:34
|
|
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.
|
|

10-05-04, 00:42
|
|
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.
|
|

10-05-04, 00:52
|
|
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.
|
|

10-05-04, 15:24
|
|
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.
|
|

10-05-04, 20:40
|
|
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.
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|