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

高洛峰
Release: 2017-03-06 17:01:57
Original
1461 people have browsed it

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 AAA
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
, while the line break in TextArea is /n

Problem solution 2:
Submit the data first and then use Javascript Replace
and /n
When submitting, still use
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>
Copy after login


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!

Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template