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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text to Hyperlink Conversion 2

Status
Not open for further replies.

tonys123

IS-IT--Management
Apr 30, 2007
46
GB
Hi Guys. I have an application in ASP which has a text box into which users can enter whatever they wish. As part of that input, I'd like to be able to automatically convert certain text to hyperlinks automatically (e.g. Does anyone know how I can do this? Thanks.
 
I think you should store the input "as-is" and only replace the text with hyperlinks "on the way out" if that makes sense.

You can work something up using InStr() but if you have complicated rules of replacement you'll be better off using "regular expressions".
 
Good idea. What I'll do is do the conversion on click of the Save button. If I get the users to preface these potential links with 'http', I guess I could search all the text for strings beginning http and that would get the http and https links. But once I have done that, how do I do the actual conversion to the hyperlink? I'm not to clear on this side of things. Is there a command that will do it for me? Thanks
 
ok well a hyperlink is just text as far as your ASP is concerned... it is the browser that sees certain text and makes it into a link, right?

So if you had:[tt]
MyString = "The quick brown fox jumped over the lazy dog."[/tt]

And if you wanted to locate the character position of the word "fox"...
[tt]
StartPosition = InStr(MyString, "fox")
If StartPosition > 0 Then
Response.Write "Fox found at position " & cStr(StartPosition)
End If
[/tt]

And if you wanted to replace "brown" with "red" ....
[tt]
MyString = Replace(MyString, "brown", "red")
[/tt]




 
OK....So I guess that if I am simply redisplaying the data in a text box, then I'm not going to get the hyperlink - or am I being dense and missing the point? Sorry to be slow but I am very new to this environment; my previous area of expertise was more the DB side of things. Or would I just search for my string and display the link outside my text box?
 
I was assuming the user would input the data into a textbox but then you would output the data onto a web page.

I don't think you can make a hyperlink inside a textbox because that would interfer with the ability to edit the text.

I think I am misunderstanding something here.
 
You have clarified exactly what I need to do to make this work...and why it wasn't before. Many thanks.
 
Thanks for the star and I'm glad it is clarified for you but I am still confused.
 
Chris - thanks for the link. It does exactly what I was hoping for. It is all now working perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top