Textarea value not getting posted with form
Asked Answered
I

12

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.

Ignoble answered 15/9, 2013 at 19:43 Comment(0)
A
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>
Agadir answered 15/9, 2013 at 19:46 Comment(4)
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.Ignoble
provide the from id instead name with same value and then tryAgadir
Thank you! That was it. I though it was the name of the form that had to be set.Ignoble
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.Lowndes
B
10

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

Buoyage answered 13/11, 2015 at 15:2 Comment(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.Buoyage
A
10

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

Allpurpose answered 24/10, 2018 at 21:22 Comment(2)
Thanks -- got bitten by this one just now!Huehuebner
Thank you for this! I'm using Sublime Text and name isn't a suggestion for the <textarea> element!Stupor
A
4

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>
Athallia answered 17/2, 2019 at 6:50 Comment(0)
B
3

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.

Brandabrandais answered 15/9, 2013 at 19:45 Comment(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.Ignoble
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/…Brandabrandais
B
2

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

Benediction answered 12/12, 2017 at 17:53 Comment(0)
C
2

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

Cephalic answered 26/3, 2020 at 14:32 Comment(0)
T
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.

Task answered 6/11, 2018 at 18:9 Comment(0)
C
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

Comanchean answered 23/11, 2017 at 4:50 Comment(0)
D
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.

Deerskin answered 25/9, 2020 at 12:34 Comment(0)
F
-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>
Fineable answered 11/12, 2016 at 0:30 Comment(0)
I
-2

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

Insinuating answered 6/4, 2022 at 11:2 Comment(1)
Low quality answer, please add more detailsGreathouse

© 2022 - 2024 — McMap. All rights reserved.