Home >Web Front-end >HTML Tutorial >Summary and Analysis of Textarea Line Breaking Problems in HTML
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(' ','/n'); 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!