2

I cannot get text from my textarea :

Very simple textarea :

<textarea id="message" placeholder="Type your text here..."></textarea>

My dart code :

var area = document.query('#message');
document.query("#send").on.click.add((e) { 
   print('send ${area.text}');
});

When i write a message in area and press send , just display :

send

I don't understand why my message is not print. 'text' is not the correct field ? (same problem with innerHtml) When I add

area.text = 'Hello';

The message is visible in textarea and print is well.

Shailen Tuli
  • 13,815
  • 5
  • 40
  • 51
  • I've never used Dart, but try `area.value` instead. It sounds like `text` just gets the children of the *node* as text. – Ry- Jul 28 '12 at 23:35

1 Answers1

7

Use area.value instead of area.text. area.value is a property of TextAreaElement that gets the actual value displayed, whereas area.text is a property of Node that gets or sets the content of area as a text node.

Ry-
  • 218,210
  • 55
  • 464
  • 476
  • 1
    My problem was Dart Editor put a warning on the area.value. But if I declare the area as TextAreaElement works fine : TextAreaElement area = document.query('#message'); – Nicolas François Jul 29 '12 at 09:48