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.

Edison Biba
  • 4,384
  • 3
  • 17
  • 33
Juicy
  • 11,840
  • 35
  • 123
  • 212

12 Answers12

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>
Ahsan Shah
  • 3,931
  • 1
  • 34
  • 48
  • 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 '13 at 19:48
  • 11
    provide the from id instead name with same value and then try – Ahsan Shah Sep 15 '13 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 '13 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 – trinity420 Nov 10 '17 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

Fabio
  • 3,015
  • 2
  • 29
  • 49
  • @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. – Fabio Oct 11 '18 at 09:56
9

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

Ojas Kale
  • 2,067
  • 2
  • 24
  • 39
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>
bara batta
  • 1,002
  • 8
  • 8
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.

Elliot Lings
  • 1,096
  • 1
  • 9
  • 16
  • 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 '13 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. http://net.tutsplus.com/tutorials/chrome-dev-tools-networking-and-the-console/ – Elliot Lings Sep 15 '13 at 19:50
2

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

Shivanshu
  • 1,230
  • 1
  • 11
  • 17
2

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

Panu Haaramo
  • 2,932
  • 19
  • 41
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.

J. Ternent
  • 116
  • 1
  • 6
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

Kaustubh Khare
  • 3,280
  • 2
  • 32
  • 48
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>
Adam
  • 5,403
  • 6
  • 31
  • 38
nqkhanh
  • 1
  • 2
-1

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