Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Textarea value not getting posted with form

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.

like image 959
Juicy Avatar asked Sep 15 '13 19:09

Juicy


People also ask

Can textarea be used in form?

The <textarea> tag defines a multi-line text input control. The <textarea> element is often used in a form, to collect user inputs like comments or reviews. A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).

Can I use textarea in a form in HTML?

Yes you can use textarea tags outside of a form and they will display and allow text to be inserted and edited, but not being tied to a form their uses will likely be limited.

How do I display textarea content in HTML?

Use the <textarea> tag to show a text area. The HTML <textarea> tag is used within a form to declare a textarea element - a control that allows the user to input text over multiple rows. Specifies that on page load the text area should automatically get focus.

Does textarea have value attribute?

<textarea> does not support the value attribute.


2 Answers

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> 
like image 70
Ahsan Shah Avatar answered Oct 08 '22 03:10

Ahsan Shah


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

like image 23
dietbacon Avatar answered Oct 08 '22 05:10

dietbacon