47

I'm trying to input a textarea tag when I submit my form:

<textarea id="confirmationText" class="text" cols="86" rows ="20" name="confirmationText" form="confirmationForm"></textarea>

<form action="sendConfirmation.php" name="confirmationForm" method="post">
   <input type="submit" value="Email" class="submitButton">
</form>

As you can see I've set the form="confirmationForm" attribute in my textarea tag. I've used Live HTTP Headers to catch the POST request and it is empty (so I know the problem is not in sendConfirmation.php, the problem is that the confirmationText is not being POSTed). I've searched the net and as far as I can see I've set it correctly.

12 Answers 12

46

try to put it inside the form tag as follows... it should work

<form action="sendConfirmation.php" name="confirmationForm" method="post">
    <textarea id="confirmationText" class="text" cols="86" rows ="20" name="confirmationText"></textarea>

   <input type="submit" value="Email" class="submitButton">
</form>

however you can use the same approach as well but you need to provide the from id attribute then

<form action="sendConfirmation.php" id="confirmationForm" method="post">
   <input type="submit" value="Email" class="submitButton">
</form>
4
  • 1
    It still doesn't work. I've actually read that if you set the "form" attribute of your input tags you don't need to put them inside the < form > tags. I tried it anyway. The contents are still not being posted.
    – Juicy
    Sep 15, 2013 at 19:48
  • 11
    provide the from id instead name with same value and then try
    – Ahsan Shah
    Sep 15, 2013 at 19:49
  • Thank you! That was it. I though it was the name of the form that had to be set.
    – Juicy
    Sep 15, 2013 at 19:50
  • 3
    What solved my error was just to set the id AND name attributes of the textarea to the exact save value! For example <textarea id="myText" name="myText">. Regardless of the form.
    – trinity420
    Nov 10, 2017 at 19:09
9

You must put in the form attribute of the textarea the form's id, not it's name.

try:

<textarea id="confirmationText" class="text" cols="86" rows ="20" name="confirmationText" form="confirmationForm"></textarea>

<form action="sendConfirmation.php" id="confirmationForm" name="confirmationForm" method="post">
   <input type="submit" value="Email" class="submitButton">
</form>

source: http://www.w3schools.com/tags/att_textarea_form.asp

1
  • @WalrustheCat isn't flask a backend framework? If so, it should have no influence on this as it only handles data after it's been submitted in the request. Try sending your code here and I can see if I can find whatever's wrong.
    – dietbacon
    Oct 11, 2018 at 9:56
9

Make sure you are not missing out on name attribute of textarea tag. This happend to me in django.

2
  • 1
    Thanks -- got bitten by this one just now!
    – abey
    Jul 15, 2019 at 18:47
  • Thank you for this! I'm using Sublime Text and name isn't a suggestion for the <textarea> element!
    – Plantt
    Nov 4, 2022 at 13:04
3

Just Add Form="formId" attribute to TextArea tag and Assign Id to Form

<textarea id="confirmationText" class="text" cols="86" rows ="20" name="confirmationText" form="confirmationForm"></textarea>

<form action="sendConfirmation.php" id="confirmationForm" name="confirmationForm" method="post">
   <input type="submit" value="Email" class="submitButton">
</form>

2

You need to put your textarea inside the form tag

 <form action="sendConfirmation.php" name="confirmationForm" method="post">
    <textarea id="confirmationText" class="text" cols="86" rows ="20" name="confirmationText" form="confirmationForm"></textarea>
    <input type="submit" value="Email" class="submitButton">
</form>

When a form is submitted everything inside it is sent, any inputs outside the form tag are ignored.

2
  • 2
    It still doesn't work. I've actually read that if you set the "form" attribute of your input tags you don't need to put them inside the < form > tags. I tried it anyway. The contents are still not being posted.
    – Juicy
    Sep 15, 2013 at 19:48
  • 3
    If you're using Chrome or Firefox you can open up Dev Tools, go to the Network tab and when you submit the form check the data is being submitted, this will help you figure out if it's because of a client-side or server-side issue. net.tutsplus.com/tutorials/… Sep 15, 2013 at 19:50
2

I was having the same issue, got it resolved by adding method="post" in textarea.

2

I had disabled="disabled"attribute in my textarea. It will prevent submitting input as well.

1

Bit of a necro here but it's still high in the Google search rankings, so adding my 2 cents -- what finally worked for me was NOT using the form= attribute if the textarea is inside the form. Even though the name was the same as the form's name, it didn't work until I removed the form= bit. Tried defaultValue, tried putting some text in the textarea itself, none of those helped.

0
<form action="sendConfirmation.php" name="confirmationForm" method="post">
<textarea id="confirmationText" class="text" cols="86" rows ="20" name="confirmationText" form="confirmationForm"></textarea>
   <input type="submit" value="Email" class="submitButton">
</form>

<form action="sendConfirmation.php" name="confirmationForm" method="post" id="confirmationForm">

you need to add id in the form tag

textarea form="confirmationForm" match form id="confirmationForm"

try it

0

It will work.

<textarea id="confirmationText" class="text" cols="86" rows ="20" name="confirmationText" form="confirmationForm"></textarea>

<form action="sendConfirmation.php" id="confirmationForm" method="post">
   <input type="submit" value="Email" class="submitButton">
</form>

Just change or add the form attribute in the textarea tag with value of the id of the form tag.

-1

Try to put it beside the form tag as follows... It should work.

<form action="sendConfirmation.php" name="confirmationForm" method="post">
<textarea id="confirmationText" class="text" cols="86" rows ="20" name="confirmationText" form="confirmationForm"></textarea>
   <input type="submit" value="Email" class="submitButton">
</form>
-1

You can see your post data in viewpagesource, HTML tag is not print like a data.

1
  • Low quality answer, please add more details
    – Zach Jensz
    Apr 9, 2022 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.