This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Text Area Formatting  RSS feed

 
Chitra Sen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I saw one of the post regarding textarea formatting. I need a clear idea of how to retain the format entered in the text area . The data entered goes to the database and i retrieve it from the database.
I don't know whether it goes with new line characters or not becoz
if i write
Hi,
This is your friend,
bye,
cs.
This gets me as Hi,This is your friend,bye,cs. all in one line
Anybody pls hlp.
 
P. Udaya Shankar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
to come the new line u will press enter key right,
which wont store in the db, if u want it u have specify with the escape
seqence character
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shouldn't it be stored OK if you use a prepared statement?
 
Nagaseshagiri poola
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
No it should not be and you'll get the same format as you entered in to the textarea. may be you need to check how the value is stored in the database. just look at the data base field using the data field.
have a nice time
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I personally escape the whole text area with a function and store it into the database. When I retrieve the information it will display the way that I want it to. I also use someother function to find links, custom tags, etc.
Eric
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup go with Eric's idea. That is what I do too.
To check the newline character, I check for "\n", single quotes, double quotes, etc and replace them with escape sequence. Instead of directly storing in the DB, let it go through some function first.
This is the replace function I generally use :

hth
MB
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!