Sportsquid
Sportsquid

Reputation: 1

How do I save a textarea in html?

I am making a program and I made a text area

document.write('<textarea id="text1" rows="10" cols="50"></textarea>')

I need to save the users input to a variable but no matter what I do it wont work. Instead of the users text it, just says HTML Text Area

What do I do?

Upvotes: 0

Views: 102

Answers (2)

Gin
Gin

Reputation: 1

You should get the DOM Element first like var textarea = document.getElementById('yourTextArea')

then get the value by textarea.value

Upvotes: 0

Dan H
Dan H

Reputation: 626

var data = document.getElementById('yourTextAreaId').value;

Upvotes: 1

Related Questions