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

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

10-04-04, 22:29
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
well I tried to look at your page as an example but it failed so....
|
|

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

10-04-04, 23:34
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
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-04-04, 23:42
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 494
|
|
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-04-04, 23:52
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
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, 14:24
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 494
|
|
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, 19:40
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
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
|
|
|
|
|