The textarea element represents a multi-line plain-text editing control,
useful when you want to allow users to enter a sizeable amount of free-form text, for
example a comment on a review or feedback form
An id attribute allows the textarea to be associated with a
label element
A name attribute sets the name of the associated data submitted to the
server
rows
The number of visible text lines for the control
If it is specified, it must be a positive integer
If it is not specified, the default value is 2
cols
The visible width of the text control, in average character widths
If it is specified, it must be a positive integer
If it is not specified, the default value is 20
Default content is entered between the opening and closing tags
textarea does not support the value attribute
The textarea tag is an escapable raw text (type 4) HTML
element
(title is another)
Escapable raw text elements can have text and character references
(HTML entities)
The textarea element also accepts several attributes common to form
input
elements, such as
autocapitalize
autocomplete
autofocus
disabled
placeholder
readonly
required
Example
HTML
<label for="story">Tell us your story:</label>
<form id="form_one">
<textarea
id="story"
name="param1"
rows="5"
cols="33"
maxlength="200">
It was a dark and stormy night...
</textarea>
</form>
Browser
JavaScript
async function sendData() {
const formData = new FormData(form_one);
try {
const response = await fetch("https://php.tomgdow.com", {
method: "POST",
body: formData
});
let result = await response.text();
console.log(result);
let responseArray = result.split('&');
document.getElementById('myoutput').value = responseArray[0];
} catch (e) {
console.error(e);
}
}
document.getElementById('form_one').addEventListener('submit', function (event) {
event.preventDefault();
sendData();
});