It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming ASP & ASP.NET Forum

asp formatting for text box

asp formatting for text box

Postby dizzy on Mon Oct 11, 2004 4:02 am

Hi,
I have to use the nl2br function in the asp file, luckly I got this code from a site.

<%
function nl2br(str)
nl2br=replace(str,VbCrLf, "<br >")
end function
response.write nl2br(essay)
%>

but I am from PHP world I dont understand ASP, for the time being I have to use this function in ASP mail script that uses CDONTS to send email.

in that email script the html form in sending variable to this asp script and then it sends a mail with the content showing all the variables inside the table. The code where the value of the variables is displayed is something like

"<tr><td>Essay</td><td>" & essay & "</td></tr>"


Where my variable essay is displayed between & & now I dont know where to put that nl2br function

when i write & response.write nl2br(essay) & it shows error when i remove the & it again shows error.

Please help me and sorry for being so dump in sorting such a simple thing.


And yes the script works without the nl2br


regards
dizzy
<%
Function Fixquotes(theString)
Fixquotes = Replace(theString,"'","''")
End Function
Function sendmail( fromwho, towho, subject, body)
Dim objNewMail
Set objNewMail = Server.CreateObject("CDONTS.NewMail")

objNewMail.From = fromwho
objNewMail.To = towho
objNewMail.Bcc = bccwho
objNewMail.Subject = subject
objNewMail.BodyFormat = 0
objNewMail.MailFormat = 0
objNewMail.Body = body

On Error Resume Next
objNewMail.Send
set objNewMail = nothing
If Err <> 0 Then
sendmail = "ERROR"
else
sendmail = "SUCCESS"
End If


End Function

Name=Fixquotes(trim(Request("FName")))
age=Fixquotes(trim(Request("age")))
Nationality=Fixquotes(trim(Request("nationality")))
email=Fixquotes(trim(Request("email")))
Address=Fixquotes(trim(Request("Address")))
Phone=Fixquotes(trim(Request("phone")))
Profession=Fixquotes(trim(Request("profession")))
Education=Fixquotes(trim(Request("education")))
Essay=Fixquotes(trim(Request("essay")))

function nl2br(str)
nl2br=replace(str,VbCrLf, "<br >")
end function


Subject = "Strategic Foresight Group Essay Contest"

body = "<table border =1><tr><td>Name</td><td>"& Name & "</td></tr>" & _
"<tr><td>Age</td><td>" & age & "</td></tr>" & _
"<tr><td>Nationality</td><td>" & nationality & "</td></tr>" & _
"<tr><td>Email</td><td>" & email & "</td></tr>" & _
"<tr><td>Address</td><td>" & address & "</td></tr>" & _
"<tr><td>Phone</td><td>" & Phone & "</td></tr>" & _
"<tr><td>Profession</td><td>" & profession & "</td></tr>" & _
"<tr><td>Education Level</td><td>" & education & "</td></tr>" & _
"<tr><td>Essay</td><td>" & response.write nl2br(essay) & "</td></tr>"

towho = "me@mydomain.com"


Dim Status
Status = sendmail(name, towho, subject, body)


Response.Redirect "index.htm"
Response.End()
%>
dizzy
 
Posts: 0
Joined: Mon Oct 11, 2004 3:57 am

Postby Malcolm on Mon Oct 11, 2004 2:33 pm

Try replacing:
Code: Select all
"<tr><td>Essay</td><td>" & response.write nl2br(essay) & "</td></tr>"

With
Code: Select all
"<tr><td>Essay</td><td>" & nl2br(essay) & "</td></tr>"
Image
User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada


Who is online

Users browsing this forum: No registered users and 2 guests