HTML textarea输入不能识别换行符 [英] HTML textarea input doesnt recognize line breaks

查看:753
本文介绍了HTML textarea输入不能识别换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常愚蠢的问题,但我找不到解决问题的方法,
我编程一个帮助台系统,支持票
我在我的网站上有一个表格,如

 < form action =somepage.phpaction =post> 

< input id =replytype =textarea>

< button id =replyButtontype =submit>提交< / button>

< / form>

但是当用户提交文本时,我将它显示在网站上作为用户之间的对话和支持助理,它不承认换行符,我不知道它是否放置\ n \r或#10#13,甚至没有...



我测试过,当我按下输入文本区域,然后单击提交,当我从我的数据库中得到相同的文本时,我得到了EMPTY SPACES的换行符应该是...



BTW>在使用utf8_enconde($ text)显示文本之前,因为人们正在输入speciales字符,比如带有尖锐字母的字母。 >

在HTML中,您可以使用

 < br> 

标记换行符。用所述标记替换所有换行符(换行符),并且应该。您可以使用 nl2br()(它真的只在换行符后面插入这样的标签(换行符)。


I have a really silly problem, but i cannot find a way to solve it, I programming a helpdesk system, with support Tickets I have a form in my website like

<form action="somepage.php" action="post">

<input id="reply" type="textarea">

<button id="replyButton" type="submit">Submit</button>

</form>

but when the user submits the text, and i show it in the website as the conversation between the user and the support assistant, it doesnt recognize the line breaks, i dont know if its putting \n\r or #10#13, or even nothing...

i've tested and when i press enter in the text area and click submit, when i get that same text from my database i get EMPTY SPACES where the linebreaks should be...

BTW> before displaying the text im using utf8_enconde($text) because people are typing speciales characters like letters with acute and ñ

解决方案

In HTML you use the

<br>

tag for line breaks. Replace all line breaks (newline characters) with said tag and you should be fine. You can "convert" line breaks (newline characters) to that tag using nl2br() (it really only insert such tags after line breaks (newline characters).

这篇关于HTML textarea输入不能识别换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆