开发者

Text formatting within textarea

开发者 https://www.devze.com 2022-12-24 09:54 出处:网络
Variations on my problem have been discussed elsewhere, so I hope I\'m not duplicating! I\'m implementing a simple Private Messaging System as part of a web app. I\'ve got an annoying problem though w

Variations on my problem have been discussed elsewhere, so I hope I'm not duplicating! I'm implementing a simple Private Messaging System as part of a web app. I've got an annoying problem though when dynamically inserting text into a textarea box in order to make a reply. Getting the content and displaying it is fine, but I can't work out how to format it correctly. Obviously, I can't use html tags, but plain text formatting like line breaks and carriage returns seem to be ignored too. This happens when an existing message is being displayed either as part of开发者_高级运维 a reply or as a thread in a new message. How do I check what formatting is being saved in my db? Or indeed what formatting is being sent back from my db?!


What about using some for of HTML editor for the replies. Save the html in the database and shown them again in the editro on your web site.

Check this wiki page for a list of possible editors


UPDATE:

Thanks for your replies, but I've worked it out. I was playing around and realised the problem was at the stage of sending the data to the db. I passed the text through the nl2br() function before sending it to the db and this seems(!) to have done the trick!

0

精彩评论

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

关注公众号