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

Keeping format when inserting into DB

Status
Not open for further replies.

billkeziah

Programmer
May 18, 2001
6
US
I have a form that uses <TEXTAREA> as a user input. Can anyone tell me how to keep the format (i.e. carraige returns, spaces, etc) when using the form to populate an MS Access database? As well, how do I return information from the database to the user keeping the format?
 
Here's what I do, maybe this will work for you. The TEXTAREA tag supports three wrap attributes: off, hard, and soft. I am using &quot;wrap=hard&quot; to do what you are asking. This is what it looks like on the form page.
Code:
<TEXTAREA NAME=&quot;Description&quot; ROWS=5 COLS=73 STYLE=&quot;Width=100%&quot; WRAP=&quot;hard&quot;>N/A
To display it, it goes something like this:
[CODE]
<CFOUTPUT QUERY=&quot;GetServiceInfo&quot;>
			<TABLE CLASS=&quot;Level2&quot;>
			<TR>
			   <TD><PRE>#ServiceDescription#</PRE></TD>
			</TR>
			</TABLE>
			</CFOUTPUT>
Please note the PRE tag. That's what does it. Calista :-X
Jedi Knight,
Champion of the Force
 
I also use the following to replace carriage returns and linefeeds in text entered for use on web pages. Using this syntax a user can still enter any HTML and other formatting if they wish, but the CR/LFs are replaced by code to properly display as well.

#replace(TEXTSTRING,&quot;#chr(10)#&quot;,&quot;<br>&quot;,&quot;all&quot;)#

Simply insert the field or variable in place of TEXTSTRING and your output will appear the same way it was entered. Mitch Duszynski
Web Developer
Human Kinetics
PO Box 5076, Champaign, IL 61825
Tel: 217-351-5076 x2474 | Fax: 217-351-2674
mitchd@hkusa.com |
 
Thanks, Mitch! I like your solution better than mine. Your suggestion works great for text, but what do I do about tables? If I paste a table into the textarea, insert it into the database, then retrieve it from the database and display it, there are 10 - 20 blank lines before the table. The table itself looks fine, it''s all those blank lines that is a problem. I went into the database and manually deleted all the BRs and special character within the table, and that got rid of the blank lines. What can I do with this table on its way into the database to prevent this problem? My TEXTAREA needs to accomodate a combination of text and tables Calista :-X
Jedi Knight,
Champion of the Force
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top