Format TD based on Fomat used in TextArea

mountainbiking
12-04-2006, 02:07 PM
I have a form where users add data. Simailar to these message boards... users add questions in a textarea. When the data is submitted it is displayed in a table. How can I apply the same formatting to the <TD> as the <textarea> has? An example could be a user adds this to a textarea:

This is a test.

My name is User.

Thanks.

But in the <TD> it will display This is a test. My name is User. Thanks.


Any thoughts on this would be appreciated.

Volte
12-04-2006, 02:08 PM
What language are you using?

mountainbiking
12-04-2006, 02:19 PM
Sorry, I forgot to mention that I am using ASP/HTML


I have a form where users add data. Simailar to these message boards... users add questions in a textarea. When the data is submitted it is displayed in a table. How can I apply the same formatting to the <TD> as the <textarea> has? An example could be a user adds this to a textarea:

This is a test.

My name is User.

Thanks.

But in the <TD> it will display This is a test. My name is User. Thanks.


Any thoughts on this would be appreciated.

Volte
12-04-2006, 02:21 PM
Here is a link that describes the basics of transferring and displaying data over multiple pages using HTML forms with ASP: http://www.w3schools.com/asp/asp_inputforms.asp

And here is a link that describes HTML forms themselves: http://www.w3schools.com/html/html_forms.asp

mountainbiking
12-04-2006, 02:34 PM
Thanks for the links.... that doesn't tell me anything I already don't know though... I am an experienced programmer... one thing I have never had the need to do is format data in a table as it is entered in a textarea. The link you sent is 101 for people just familiarizing themselves with HTML forms.

I know that some how 'behind the scenes' when a user is entering data in a textarea and the press enter for the next line that when the data is displayed in HTML that a <BR> will be required I just don't know how to tell the <TD> to display information as added in the textbox. The DB holds the formatting because if a user edit's data the data appears with all the proper formatting in the textarea.

Here is a link that describes the basics of transferring and displaying data over multiple pages using HTML forms with ASP: http://www.w3schools.com/asp/asp_inputforms.asp

And here is a link that describes HTML forms themselves: http://www.w3schools.com/html/html_forms.asp

Volte
12-04-2006, 02:38 PM
Ah sorry if I seemed patronizing; I guess I misunderstood the question. Are you saying you want to fix the line-breaks? In that case you should be able to use the Replace() function to replace vbCrLf with "<br>vbCrlf", assuming I am understanding correctly how the data is stored in the database.

mountainbiking
12-04-2006, 02:51 PM
Think about when you type in a reply to this post... when i press enter
It goes to the next line.

I want this formatting to portray to the <TD>.

This website is a good example because this does exactly what I am looking to do.

Is my request clear or do I need to provide more info? Just think when you are reading this that this is exactly how I typed it in the textarea.... and when strong to the DB the value in the textarea does not have any vbCrlf. It just has straight text, but when editing the text in the textarea, the same attributes in terms of formatting is returned.


Ah sorry if I seemed patronizing; I guess I misunderstood the question. Are you saying you want to fix the line-breaks? In that case you should be able to use the Replace() function to replace vbCrLf with "<br>vbCrlf", assuming I am understanding correctly how the data is stored in the database.

Volte
12-04-2006, 03:00 PM
It seems strange to me that it's not storing the vbCrLf. What are you using to view the contents of the database? Does it appear formatted correctly in the source code of the page if you View->Source?

wayneph
12-04-2006, 03:03 PM
I'd personally use something like www.fckeditor.net to enter the data. Then they will enter the data like they want it displayed. I prefer it to a TextArea, and the proper HTML is stored.

Otherwise, you will have to manually replace vbCrLf with <br />.

mountainbiking
12-04-2006, 03:06 PM
I am using Access for this particular application.... everything looks normal... look at the example I created of formatting:

<textarea rows="11" name="S1" cols="49">This is a test
I
Love
America

The End</textarea>

If you copy that text to a HTML editor it will display with the spacing.....

It seems strange to me that it's not storing the vbCrLf. What are you using to view the contents of the database? Does it appear formatted correctly in the source code of the page if you View->Source?

wayneph
12-04-2006, 03:20 PM
I guess another option would be to change the whitespace css property in your table cell.

<td style="white-space:pre;">I
Love
America

The End</td>

mountainbiking
12-05-2006, 07:10 AM
All the CSS properties I have played with don't give me the formatting that i need either. I am surprised that the <textarea> is not giving me a vbcrlf when the user presses enter. It doesn't though. Below is the text from one of the tables that I wast to display the proper format from the textbox.


<td colspan="5" align="center">
<p align="left"><b>nbsp;Team,

FYI, just wanted to let everybody know that if you need to add F8 to a 2F application.

</b></td>

You can see the DB returns the fact that there was a carriage return as shown in Team,

FYI....


Any other suggestions?

wayneph
12-05-2006, 07:23 AM
It IS giving you a vbCrLf. HTML ignores it by design. White Space doesn't matter. That's why I suggested changing the way the white space property is set up.

Try something like this (which I also mentioned in post 9)...
<td>Replace(rs("yourField"), vbCrLf, "<br>")</td>

This will explicitly replace the New Line with the appropriate HTML equivalent.

mountainbiking
12-05-2006, 07:37 AM
Wayneph:

Thanks you were correct. I had the same string in there last night except by accident I placed quotes around the vbcrlf like below:


<td>Replace(rs("myfield"), "vbCrLf", "<br>")</td>

I removed them and it worked great. Thanks for the good eye on the important details.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum