问题:
I am creating a form for medical prescription. Here one of the textarea field name is new prescription. Doctor will insert value here like
1. medicine-l
1+1+1
2. medi...
可以将文章内容翻译成中文,广告屏蔽插件会导致该功能失效:
问题:
I am creating a form for medical prescription. Here one of the textarea
field name is new prescription
. Doctor will insert value here like
1. medicine-l
1+1+1
2. medicine-2
1+0+1
But while I print out the prescription this new prescription
field shows it's value like
1.medicine-1 1+1+1 2.medicine-2 1+0+1
But I want to printout the value of new prescription
just like how doctor inserted.
How can I do it? Anybody Help Please ?
回答1:
The line breaks are actually preserved untill you print the text out. HTML doesn't doesn't detect the line breaks in the text.
Try this for JS:
textAreaText.replace(/(?:rn|r|n)/g, '<br>');
How do I replace all line breaks in a string with <br /> tags?
Try this for PHP : http://php.net/manual/en/function.nl2br.php
回答2:
You should be able to do this using the CSS property white-space
.
Example:
.textarea-class {
white-space: pre-wrap;
}
Consult the MDN docs for a very nice overview if the various options, but it seems like you want either pre
(just as it is), pre-wrap
(maintains spacing and line breaks, but wraps), or even pre-line
(maintains line breaks but not spacing, and wraps).
You’ll want to put this in your print stylesheet.