I only want to maintain the paragraph structure of the users input into a textbox. When I retrieve the text from db, all structure is lost. What's easiest way to save text as recorded?
A:
replace spaces " " with
You can't repeat multiple spaces " " in HTML, as they will be collapsed into one space.
Also, replace \n with <br />
Hope that helps!
ItzWarty
2010-02-25 05:46:24
Whilst this will work, it's a lot of hassle, compared to wrapping the text in a <pre></pre> element, as suggested by @Skay. You would need to consider tabs too, which is a whole new ball game.
belugabob
2010-02-25 08:49:11
A:
If you want to store HTML text (rich text with BOLD , Italic and etc) you have to use an editor like CKEditor (http://www.ckeditor.com)
Nasser Hadjloo
2010-02-25 05:47:06
The question was not about entering HTML, it was about preserving and displaying the whitespace that is inherent in the text entered via a textbox (I'm presuming a <textarea> element)
belugabob
2010-02-25 08:47:11