473,390 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

ASP form textbox to HTML formatting

Hi,
I have to use the nl2br function in the asp file, luckly I got this
code from a site. What I need done is to display textbox content the
way it was typed/pasted i.e. with paragraph breaks and color
formatting. The code I used is below but it does not work. Can someone
please help me out, its rather urgent and important.
<%
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
Jonathan
<%
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()
%>
Jul 19 '05 #1
8 4346

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

Jul 19 '05 #2
John wrote on 11 okt 2004 in microsoft.public.inetserver.asp.general:

<%
VbCrLf = Chr(10)&Chr(13)
You do not need to define VbCrLf, it is build in in vbscript.
function nl2br(str)
nl2br=replace(str,VbCrLf, "<br >")
end function
response.write nl2br(essay)
%>



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 19 '05 #3
Is it build in in ASP? Here when not defined i have no replace. Once defined
it works fine ???
Maybe some files are missing on servers where VBCrLf is defined
Jul 19 '05 #4
"Evertjan." <ex**************@interxnl.net> wrote in message news:<Xn********************@194.109.133.29>...
John wrote on 11 okt 2004 in microsoft.public.inetserver.asp.general:

<%
VbCrLf = Chr(10)&Chr(13)


You do not need to define VbCrLf, it is build in in vbscript.
function nl2br(str)
nl2br=replace(str,VbCrLf, "<br >")
end function
response.write nl2br(essay)
%>



Thanks for the quick response, but could you please tell me where do I
insert this code.

Regards,
Jonathan J.

Jul 19 '05 #5
Jonathan wrote on 12 okt 2004 in
microsoft.public.inetserver.asp.general:
"Evertjan." <ex**************@interxnl.net> wrote in message
news:<Xn********************@194.109.133.29>...
John wrote on 11 okt 2004 in microsoft.public.inetserver.asp.general:
>
> <%
> VbCrLf = Chr(10)&Chr(13)


You do not need to define VbCrLf, it is build in in vbscript.
> function nl2br(str)
> nl2br=replace(str,VbCrLf, "<br >")
> end function
> response.write nl2br(essay)
>> %>


Thanks for the quick response, but could you please tell me where do I
insert this code.


Somewhere in your ASP vbscript code, Jonathan.

ASP is what this NG is all about.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 19 '05 #6
"Evertjan." <ex**************@interxnl.net> wrote in message news:<Xn********************@194.109.133.29>...
Jonathan wrote on 12 okt 2004 in
microsoft.public.inetserver.asp.general:
"Evertjan." <ex**************@interxnl.net> wrote in message
news:<Xn********************@194.109.133.29>...
John wrote on 11 okt 2004 in microsoft.public.inetserver.asp.general:

>
> <%
> VbCrLf = Chr(10)&Chr(13)

You do not need to define VbCrLf, it is build in in vbscript.

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


Thanks for the quick response, but could you please tell me where do I
insert this code.


Somewhere in your ASP vbscript code, Jonathan.

ASP is what this NG is all about.

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

I can paste this function anywhere in the ASP file but where do I
embed the value of var essay
and should we use response.write and how do we tackle that

thanks
Jul 19 '05 #7
as*******@yahoo.com (Jonathan) wrote in message news:<81**************************@posting.google. com>...
"Evertjan." <ex**************@interxnl.net> wrote in message news:<Xn********************@194.109.133.29>...
Jonathan wrote on 12 okt 2004 in
microsoft.public.inetserver.asp.general:
"Evertjan." <ex**************@interxnl.net> wrote in message
news:<Xn********************@194.109.133.29>...
> John wrote on 11 okt 2004 in microsoft.public.inetserver.asp.general:
>
> >
> > <%
> > VbCrLf = Chr(10)&Chr(13)
>
> You do not need to define VbCrLf, it is build in in vbscript.
>
> > function nl2br(str)
> > nl2br=replace(str,VbCrLf, "<br >")
> > end function
> > response.write nl2br(essay)
> >> %>

Thanks for the quick response, but could you please tell me where do I
insert this code.


Somewhere in your ASP vbscript code, Jonathan.

ASP is what this NG is all about.

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

I can paste this function anywhere in the ASP file but where do I
embed the value of var essay
and should we use response.write and how do we tackle that

thanks


Hi Evertjan,

Was waiting for your reply as I need to be able to do this urgently.

Using the code I have posted above can you tell me where and how I
should insert the piece of code that you sent me.

Thanks
Jul 19 '05 #8
Jonathan wrote on 15 okt 2004 in microsoft.public.inetserver.asp.general:
> >> > function nl2br(str)
> >> > nl2br=replace(str,VbCrLf, "<br >")
> >> > end function

I can paste this function anywhere in the ASP file but where do I
embed the value of var essay
and should we use response.write and how do we tackle that


Hi Evertjan,

Was waiting for your reply as I need to be able to do this urgently.

Using the code I have posted above can you tell me where and how I
should insert the piece of code that you sent me.


It was not my code, only commented on the VbCrLf.

Sorry, I am afraid you don't know enough of programming to tackle this by
yourself. Either learn more or hire a programmer.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: j.t.w | last post by:
Hi All. I'm having a problem with my Date of Birth textbox. When I open the ..htm file, the "DoB" textbox is flat with a border. All of my other textboxes are sunken and are yellow. When I...
3
by: David | last post by:
Hi, I need a button shown for each record (cont. form) with specific captions on each. I have a notes form for each record. When a user presses the button they can read the notes. I want to...
4
by: cefrancke | last post by:
How does Stephen Lebans make the datasheet row color change by clicking a row's check box field? I cant find any code associated with the form, and I cant tell if you have created a class on the...
14
by: Mark | last post by:
How can the instances of a textbox control on an continuous form be addressd? Can a specific instance be addressed? For example, a continuous form has ten records. How can the textbox for the...
3
by: PeteCresswell | last post by:
Users want negative values to have a yellow background. No problem on the subforms where every value is a discreet field, but I can't figure out how to make it happen on a continuous form where...
10
by: Perry van Kuppeveld | last post by:
Hi, I have a problem with formatting a table including text fields wich can contain up to 255 chars. I need a table with 3 columns: - First column 50 % over the with a rowspan of the total...
5
by: Rob | last post by:
Hi to all. I am new to Visualbasic.net and windowz programming in general so I hope someone can help. I am trying to get info from a csv (Excell) file into a windows form. For instance I want to...
2
by: Mark Roughton | last post by:
I have a form where the users need to view records for various criteria, one of which is a date field on which they may wish to view all related data for the selected date, for all dates upto and...
5
by: Michael R | last post by:
Searching the net I've found a simple technique to add row numbers and alternate colors (for the even and the uneven row) to a continuous form. 1st step: Create a textbox, send it to background...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.