Home >Web Front-end >HTML Tutorial >Summary and Analysis of Textarea Line Breaking Problems in HTML

Summary and Analysis of Textarea Line Breaking Problems in HTML

高洛峰
高洛峰Original
2017-03-06 17:01:571394browse

Problem description:
For example, get data into a TextArea, such as "AAA BBB", and want to store this text in the TextArea by rows, instead of displaying it and storing it by rows (the so-called true storage by rows) That is, post the data of this TextArea to the Textarea of ​​another page and still store it by row)

Problem Solution 1:
When the data is submitted at the beginning, the format is AAAfde1d9378415ca5fe4c9bb67e6cfdb81 BBB, but this is displaying line breaks. In fact, it is not really stored by lines in TextArea, because when it is submitted to another TextArea at this time, AAABBB is displayed instead of line breaks, so it is only displayed by lines.

Basic knowledge of the problem:
The line break in HTML is fde1d9378415ca5fe4c9bb67e6cfdb81, while the line break in TextArea is /n

Problem solution 2:
Submit the data first and then use Javascript Replace fde1d9378415ca5fe4c9bb67e6cfdb81 and /n
When submitting, still use fde1d9378415ca5fe4c9bb67e6cfdb81 as the separator
Then after the submission is completed

The code is as follows :

<script> 
//换行转回车 
var haha=document.getElementById("SendTextArea").value; 
haha=haha.replace(&#39;
&#39;,&#39;/n&#39;); 
document.getElementById("SendTextArea").value=haha; 
</script>


That’s it!

For more related articles on the summary and analysis of Textarea line wrapping problems in HTML, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn