-4

I want to store the text users enter into a textarea in a website into a javascript variable in order to compare it to another variable already defined.

How would you do it? Any hints? Thanks in advance!

Iñaki
  • 99
  • 2
  • 10

3 Answers3

1

using jquery

var n=$('#textarea_id').val();

using javascript

var n=document.getElementById('textAreaID').value;
Deepu Reghunath
  • 8,132
  • 2
  • 38
  • 47
0

Use following code

var textareaValue = document.getElementById('textAreadID').value

Replace textAreadID with your textarea id.

Vipin Kumar
  • 6,441
  • 1
  • 19
  • 25
0

In jQuery:

var str = "compare with me",
value = $('textarea[name="yourareaname"]').val();

if(str == value) {
    alert('hell yeah');
}
Brainfeeder
  • 2,604
  • 2
  • 19
  • 37