1

I am extremely tired = extremely stupid but I want to get on with this first thing in the morning...

<div class=' form-group smhTextArea removeForAjax' style='margin-bottom: 10px'>
  <div class=''>
    <textarea class='form-control message-text-area'  rows='4'
                 name='message<?= $jj ?>' placeholder='New text box <?= $jj ?>'
                 id='message<?= $jj ?>' >
      ID <?= $jj ?> "\n" <br> Msg:<?= $stackContent ?><br>
    </textarea>
  </div>
</div>

Output comes out as:

ID 1 "\n" <br> Msg:4 Mary had a little lamb it's... ??? @ "<br>

I have looked at lots of answers on here and searched Google but can see nothing.

If this should work it is possibly that this is a very ill-formed test page at the moment.

Once again sorry if dumb but passing out here!

BeNice
  • 2,165
  • 2
  • 23
  • 38
  • 1
    Possible duplicate of [New line in text area](https://stackoverflow.com/questions/8627902/new-line-in-text-area) – DSofa Nov 06 '18 at 23:34
  • I agree BUT with the difficulty of trying to find that answer I would suggest keeping this. I spent a good 20 mins trying all combinations of "html/newline/textarea" etc before I posted this in distress. Maybe the different wording will help someone find the answer. Just a thought – BeNice Nov 07 '18 at 22:06

2 Answers2

2

The <textarea> element does not render HTML, it actually renders plain text, as its formatted in HTML file. So that means you don't have to use <br /> tag to start a new line, instead just use the regular line break (press return key on keyboard).

<textarea>Line 1
Line 2

Line 4
</textarea>
DSofa
  • 554
  • 3
  • 14
  • Think that might be problematic in grisly php code! IDEs tend to move things to new lines and then spaces get in and so on. I went with the & answer that I got from the old answer. And thanks for the useful thought that ` – BeNice Nov 07 '18 at 22:11
0

You need to use a CR/LF &#13;&#10; instead of a <BR>

<textarea> ID 1 "\n" &#13;&#10; Msg:4 Mary had a little lamb it's... ??? @ "</textarea>
JSWilson
  • 1,113
  • 1
  • 11
  • 28