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
[color green]data = Request.Form("data")[/color]
2.) Get the data into an array of words (splitting up where a space occurs)
[color green]data = Split(data, " ")[/color]
3.) Get the length of the array
[color green]datalength = UBound(data)[/color]
4.) Replace www . with the full HTML href code (for every word in the array)
[color green]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[/color]
5.) Join your string back up to output
[color green]data = Join(data, " ")[/color]
6.) Print final string
[color green]Response.Write data[/color]
Complete Code :
[color green]<%
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
%>[/color]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.