Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 2nd, 2004, 12:07 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default 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) & "" & "<b>" & mid(strSearchWithin,lngFoundPosition,len(strSearchFor)) & "</b>" & ""

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

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


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)
%>
 
Old October 2nd, 2004, 07:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi there,

Quote:
quote:There is something wrong in this. I couldn't figure it out.
So you want someone to find what is wrong? hmmm, that is tough.
How about explaining on what is "there is something wrong in this".
It is better to explain what you are trying to accomplish and what is that you are
stuck up with / trying to figure out, than expecting someone to go through the code and
analyse what it does and then find what is the clue that is being given to us here.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 2nd, 2004, 11:01 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

[u]Now after these things</u>, in the reign of Artaxerxes king[u]Now after these things[u], in the reign of Artaxerxes king of Pe[u]Now after these things</u>, 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%>
 
Old October 2nd, 2004, 11:04 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
List Box Colours Brendan Bartley Access 1 September 26th, 2007 10:16 AM
system colours DarrenMelling Pro VB 6 3 December 7th, 2006 06:22 AM
alternating colours ozPATT Excel VBA 3 October 5th, 2005 10:19 AM
Button Colours interrupt Javascript How-To 7 August 26th, 2004 04:57 PM
How Do I Print Table Cell Colours? Lucy HTML Code Clinic 4 December 3rd, 2003 12:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.