danbae danbae - 8 months ago 102
HTML Question

Sending multiline text using HTTP POST

From this answer it appears that data sent via the HTTP POST method must be present in form elements. I want to be able to send the contents of a

<textarea>
element using POST, but I imagined that
<textarea>
can't be part of a form. I could use javascript to copy the textarea contents to a (preferably hidden) form's text input field and then post. But that way the line breaks are lost. Short of inserting special chars to markup the line breaks, is there another method to preserve line breaks in POST data?

Answer Source

Actually <textarea> can be a part of a <form>:

<form action="/action_page.php" id="usrform">
  Name: <input type="text" name="usrname">
  <input type="submit">
</form>

<textarea name="comment" form="usrform">Enter text here...</textarea>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download