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

outputting data entered in a textarea (maintaining formating) 1

Status
Not open for further replies.

crystalized

Programmer
Jul 10, 2000
390
CA
Sorry everyone, I know this question has been asked before(but the answer to how to do it is not in the thread) but I need to output data entered in a text area, with the same carriage returns etc that were entered by the user in the text area.

The text area seems to handle it just fine, when I view the data from the database the carriage returns are maintained, but when I want to output the data in another manner (not in a text area) I do not receive the same formatting.

Does anyone have any suggestions. I am using Visual Interdev 6 so if any of the suggestions include the use of DTC's that would be fine with me.
 
Hey Crystalized, I had this problem a few weeks ago, but I found a solution:
____________________________________________________________
memo = server.htmlencode(request.form("message"))
for k = 1 to len(memo)
num = asc(mid(memo,k,1))
if num = 13 then
rs(&quot;message&quot;).value = rs(&quot;message&quot;).value & &quot;<br>&quot;
else
rs(&quot;message&quot;).value = rs(&quot;message&quot;).value & mid(memo,k,1)
end if
next
rs.update
____________________________________________________________
This worked for me. Before I put it in the table, I had to find all chr(13)'s and replace them with a <br>. So it spits out an html break everytime there is a chr(13). I htmlencode it first, cause I don't want to allow for html tags entered by the user.

HTH
 
A lot of times the big thing is the returns because this is what maintains the visual layout above all else. So just doing a replace(str,chr(13),&quot;<br>&quot;) on output to a browser will take care of 90% of the issue.
A text area is not an html based display, it's just a text display like notepad thus the text won't appear the same there as elsewhere in the browser.
The thing to remember is that if you do use HTMLEncode you should only do it on output to a browser. Don't do it on input to the database because you are then changing the actual text data. This can get really amusing if people are going to reedit the text because then the text will reappear in the textbox with all the encoding characters scattered around.
 
Thanks Will

I actually did use the replace exactly the way you suggested in your post, because as you say the carriage returns is really the only thing that makes a huge difference.

I found it interesting that using a label DTC with Visual Interdev I can choose to use any html tags that are included in the text being displayed. Currently I have decided that I will provide instructions so that the users can bold and italicize things if they wish to do so. Does anyone know if I am getting myself into a whole load of trouble doing this. Since only paid members can enter information I think that they may hesitate to do anything stupid with the availability of tags.... but one never knows.
 
I think if your users are trustworthy, then you don't have anything to worry about...

But there is always the chance that you'll get someone who feels slightly destructive...

I mean, what if you allow HTML, and someone starts entering server side scripting (if they know how)? couldn't they do some damage?

Just curious
 
Hello all,

here's a bigger challenge . .

How do you DISPLAY the data entered in a textarea that contain columns?

for example:

column1 column2 column3 column4
111 22 333 44444
555 -- 666 --
-- 777 888888 9999


etc?


[sig][/sig]
 
Hi greatCanada

Are you from Canada, I am as well that is why I ask. But as to the question you ask I would suggest that I can not think of any way to do such a thing effectively. The reason I say that is that the textarea's seem to ignore multiple spaces.

Originally my 1 to M forms all used a text area to show a summary of the records. However the problem was that I could not force it into a table style format so I eventually abandoned it for a grid DTC.

Maybe I am wrong with the spacing but if there is a way to accomplish it I certainly could not seem to get it to work. I am not sure of the interior spaces, but the leading ones I definitely could not get to work.

Sorry I can't be more help than that. [sig]<p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top