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

Can't break line with textarea

Status
Not open for further replies.

ewyong

Programmer
Dec 30, 2001
4
0
0
MY
Hi, I really need some help with this matter. Well you see, I am using textarea to post an article to my database, once posted to the database, everything is joined into one paragraph(eventhough I have 5). I tried using the <pre> tag but ended up having the 5 paragraph but each paragraph is so long that I have to scroll my page. How can I transfer the content to the database (using textarea) and sustain the paragraph. Thanks. :)
 
Hi ewyong, here is the explanation that will help you understand : the problematical part is not the writing into the DB, but the displaying of the data at the page(in the textarea). Here are some tips for you:
1. Within the saving of the data from forms you ony have to take into account that some DB engines will not accept some characters, such as quote or double quote. For example : you have a form on your page from which's fields you will store the data into the DB. User will write some text into the fields with quotes in it. Your DB will return error or will not store the quotes. Therefore you must to every quote in the text add one additional quote after it or before it, no matter where. The important thing is that you must do this before you send the data into the DB. You can achieve this by regular using of the REPLACE command.
2. The second thing you will do with your data will surely be the displaing of it on your webpage. Before you post any data to browser you have to Server.HTMLEncode it. Here is one very helpful function for you, which you can use for &quot;translation&quot; of the variable into the format that can be sent to browser. If you will use this you can see that all the ENTERs(in paragraphs) and all other special characters will be displayed in the right format, exactly as they were written in and submitted by the form:

function ToHTML(strValue)
if IsNull(strValue) then
ToHTML = &quot;&quot;
else
ToHTML = Server.HTMLEncode(strValue)
end if
end function

You can use it for example in this way:
Response.Write ToHTML(strTextToBeShownOnThePage)

enjoy ;)
Kamil
 
Thanks for the information, I tried and it works. But it only works when I display records in the textarea, what if I only wanted to display it as HTML. I tried using the code to display HTML but it doesn't work. Thanks again. :)
 
Hi, I have managed to fix the problem with this following line :

<% mesbody = Replace(mesbody, vbCrLf, &quot;<br>&quot;) %>

Thanks for your help. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top