Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Text withing a DB field to a Hyperlink 1

Status
Not open for further replies.

Kenny100

Technical User
Feb 6, 2001
72
NZ
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 Can I search for 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?

Thanks for any help,
Kenny.
 
Not tested, but something like this:

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

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

Dim myField
myField = &quot;some text more text&quot;
Dim i,j, cField, cLink
cField = myField
i = InStr(cField, &quot;If i <> 0 Then
j = InStr(i, cField, &quot; &quot;)
cLink = substr(cField, i, j)
response.write &quot;<a href= & cLink & &quot;>&quot; & cLink & &quot;</a>&quot;
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?

Cheers,
Kenny.
 
yep, my fault: use the mid() function.
it's my Clipper background.....
br
Gerard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top