开发者

How to preserve simple HTML formatting to textbox input?

I only want to maintain the paragr开发者_运维技巧aph 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?


use <pre></pre>


replace spaces " " with &nbsp; You can't repeat multiple spaces " " in HTML, as they will be collapsed into one space.

Also, replace \n with <br />

Hope that helps!


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜