Summary of Textarea line break issues in HTML

Summary of Textarea line break issues in HTML
Recently, I encountered a problem of whether the data can be truly stored row by row when transferred to Textrea. Here is a summary:

Problem description:
For example, get data into a TextArea, such as "AAA BBB", and want to store this text in the TextArea in real lines, rather than displaying it in lines (the so-called real line storage means that the data of this TextArea is still stored in lines when it is posted to the Textarea of ​​another page)

Problem Solved 1:
When the data is submitted at the beginning, the format is AAA<BR />BBB, but this is to display line breaks. In fact, it is not really stored in rows in the TextArea. Because when it is submitted to another TextArea, it will display AAABBB instead of line breaks. Therefore, it is only displayed as stored in rows.

Question Basics:
The line break in HTML is <BR />, while the line break in TextArea is /n

Problem Solved 2:
Submit the data first and then use Javascript to replace <BR /> and /n. When submitting, <BR /> is still used as a separator. After submitting,

Copy code
The code is as follows:

<script>
// Line break and carriage return
var haha=document.getElementById("SendTextArea").value;
haha=haha.replace('
','/n');
document.getElementById("SendTextArea").value=haha;
</script>

That’s it!

<<:  How can the front end better display the 100,000 pieces of data returned by the back end?

>>:  28 Famous Blog Redesign Examples

Recommend

【HTML element】Detailed explanation of tag text

1. Use basic text elements to mark up content Fir...

Use pure CSS to achieve switch effect

First is the idea We use the <input type="...

How to handle spaces in CSS

1. Space rules Whitespace within HTML code is usu...

Implementation of Nginx forwarding matching rules

1. Regular expression matching ~ for case-sensiti...

Use Shell scripts to batch start and stop Docker services

Table of contents Start Docker Stop Docker Python...

Detailed explanation of Socket (TCP) bind from Linux source code

Table of contents 1. A simplest server-side examp...

A brief discussion on the CSS overflow mechanism

Why do you need to learn CSS overflow mechanism i...

How to view the type of mounted file system in Linux

Preface As you know, Linux supports many file sys...

Mysql 5.7.18 Using MySQL proxies_priv to implement similar user group management

Use MySQL proxies_priv (simulated role) to implem...

MySQL 8.0.15 winx64 installation and configuration method graphic tutorial

This article shares the installation and configur...

Vue implements simple calculator function

This article example shares the specific code of ...

JavaScript design pattern learning proxy pattern

Table of contents Overview Implementation Protect...

WeChat applet tab left and right sliding switch function implementation code

Effect picture: 1. Introduction Your own applet n...