Select text in Text Field



How can I select text in Text Field via javascript?

Like when field get focus.

When I set "Allow Multiple Lines" option for Text Field, method "setFocus" does not select content of text field, as in the case when Text Field supports only one line of text.