INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Formatting

How can I format users input (for a forum entry etc) ? by BigBadDave
Posted: 20 Nov 01 (Edited 9 Jun 02)

Ever wondered how you can convert www . my-link . com, into a click-able hyperlink, when a user submits data to a forum post etc ?


Here's how :


1.) Get the data

data = Request.Form("data")

2.) Get the data into an array of words (splitting up where a space occurs)

data = Split(data, " ")

3.) Get the length of the array

datalength = UBound(data)

4.) Replace www . with the full HTML href code (for every word in the array)

For x = 0 to datalength
  If Instr(data(x),"www .") Then
    data(x) = "<a href=""h ttp://" & data(x) & """ target=""_blank"">" & data(x) & "</a>"
  End If
Next


5.) Join your string back up to output

data = Join(data, " ")

6.) Print final string

Response.Write data


Complete Code :

<%
data = Request.Form("data")
data = Split(data, " ")
datalength = UBound(data)
For x = 0 to datalength
  If Instr(data(x),"www .") Then
    data(x) = "<a href=""h ttp://" & data(x) & """ target=""_blank"">" & data(x) & "</a>"
  End if
Next
data = Join(data, " ")
Response.Write data
%>



Regards

Big Bad Dave


www.byngdesigns.co.uk

davidbyng@hotmail.com

Back to Microsoft: ASP (Active Server Pages) FAQ Index
Back to Microsoft: ASP (Active Server Pages) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close