Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Converting Text withing a DB field to a Hyperlink

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,33
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Converting Text withing a DB field to a Hyperlink
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Converting Text withing a DB field to a Hyperlink - 5/23/2001 6:50:08 AM   
  neilld

 

Posts: 13
Score: 0
Joined: 5/23/2001
From: USA
Status: offline
Hi All

Is it possible for me to search a DB field for a string and then convert that string to a web link using VBScript in conjunction with my ASP page?

The field will vary in length and may or may not contain a web address. The web address will vary in length but will always start with http://. ; Can I search for http://, strip out the address, turn it into a hyperlink and then output the entire contents of the field with the hyperlink appearing within the text?
 
 
Post #: 1
 
 Re: Converting Text withing a DB field to a Hyperlink - 5/23/2001 6:54:26 AM   
  rhl150

 

Posts: 29
Score: 0
Joined: 5/23/2001
From: New Zealand
Status: offline
Not tested, but something like this:

dim, i,j, cField, cLink
cField = rs("yourfield")
i = InStr( cField , "http://"; )
if i <> 0 then
j = InStr(i, cField, " ")
cLink = substr( cField, i, j)
response.write "<a href=http://"; & cLink &_
">" & cLink & "</a>
end if

(in reply to neilld)
 
 
Post #: 2
 
 Re: Converting Text withing a DB field to a Hyperlink - 5/23/2001 6:56:57 AM   
  neilld

 

Posts: 13
Score: 0
Joined: 5/23/2001
From: USA
Status: offline
Hi

Thanks for the response. I've tried the following:

Dim myField
myField = "some text http://www.example.com more text"
Dim i,j, cField, cLink
cField = myField
i = InStr(cField, "http://";)
If i <> 0 Then
j = InStr(i, cField, " ")
cLink = substr(cField, i, j)
response.write "<a href=http://"; & cLink & ">" & cLink & "</a>"
End If

But it doesn't like the substr part (undefined). Is this definitely a VBScript command cos I can't find it in any of my books? Any idea what's going wrong?

(in reply to neilld)
 
 
Post #: 3
 
 Re: Converting Text withing a DB field to a Hyperlink - 5/23/2001 6:58:48 AM   
  rhl150

 

Posts: 29
Score: 0
Joined: 5/23/2001
From: New Zealand
Status: offline
yep, my fault: use the mid() function.
it's my Clipper background.....

(in reply to neilld)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Converting Text withing a DB field to a Hyperlink Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts