Selecting contents of TEXTAREA by default

R

Red_Indian

Hi

How do I have the contents of a TEXTAREA selected by default when I display it to the user
(like the user doing Ctrl+A on that TEXTBOX immediately after opening the form).

Please advise.
Thanks in advance!
RI
 
M

\Mad\

How do I have the contents of a TEXTAREA selected by default when I
display it to the user
(like the user doing Ctrl+A on that TEXTBOX immediately after opening the
form).

My apologies for replying. I'm unsure of both the
correctness of my reply and the details, but maybe
I can help.


I believe, tho I could be wrong, that HTML does
not allow you to choose the "focus" of the user's
browser.


But, if the user has enabled JavaScript, and
has a reasonably recent browser
(I think IE4, Netscape 4, or later, but I
could be wrong; the tactic I'm thinking of
needs JavaScript and DOM; it might be
possible to do it with CSS, which I haven't
learned enough about yet, and which, I think,
requires an even newer browser)
then there's an event, I think maybe it's called
"OnLoad()", that can be used to trigger a
Javascript function (which you would have to
write) to move the browser's "focus" to the
document element you want selected (focused
on).


I could have two separate things confused here.
Maybe "focus" is where the "cursor" is, and
"selection" is what is highlighted. They sort of
go together, but are not exactly the same. The
JavaScript might have to set both of them. I'm
sorry, I don't remember the details, but I hope
this gives you a direction to look in JavaScript..


The "OnLoad" event (or whatever it is called;
another thing you'll have to look for; it's either
a JavaScript thing or a DOM thing, or maybe
both), if I remember correctly, is triggered
when the browser finishes downloading and
is displaying the HTML page, before turning
control over to the user.


The DOM (Document Object Model; invented
by Netscape to use with JavaScript, and so useful
that it got spread and extended) is the system of
naming parts of an HTML document as parts of
a herarchical, tree-structured view of the HTML
document, which provides names for JavaScript
(and Java, and other scripting languages,
and maybe CSS tho I could be mistaken
about that)
to use as "handles" so the JavaScript code can
"target" parts of the HTML document (the page)
to be affected or changed by the JavaScript.

It's how the JavaScript code tells the browser
_what_ to adjust on the page.


The "event" (which may be part of the DOM,
I forget exactly) , allows the JavaScript code
to tell the browser _when_ to make an
adjustment; in this case, OnLoad, after the HTML
document (webpage) is downloaded and is
being "rendered" (displayed).

I think I remember there being events like OnLoad:, :
OnMouseOver, OnKeyDown, OnKeyPress,
OnKeyUp, OnFocus, OnBlur, etc. (and problems
with overlapping events and events triggering
other events, sometimes getting stuck in a loop).


(Forgive me if you already know most of this.
I couldn't tell from your brief problem description,
and am trying to save the time that would be
used in a back-and-forth question-and-answer
session.)


Does that help any?

(And did I make any mistakes?)

(i don't know the details. I did work with some of
this, but not recently enough to have it fresh in my
mind, and I never knew all of it.)


Aloha,
 
R

Red_Indian

Mad said:
Does that help any?

Thanks a lot for that answer... especially for sparing the amount of time you did typing
that mail!

You were right... I looked around a bit and found a javascript function ".select" which
did the trick:

document.form.element.select() does it.

Thanks once again...

RI
 
R

Red_Indian

Mad said:
Does that help any?

Thanks a lot for that answer... especially for sparing the amount of time you did typing
that mail!

You were right... I looked around a bit and found a javascript function ".select" which
did the trick:

document.form.element.select() does it.

Thanks once again...

RI
 
R

Red_Indian

Mad said:
Does that help any?

Thanks a lot for that answer... especially for sparing the amount of time you did typing
that mail!

You were right... I looked around a bit and found a javascript function ".select" which
did the trick:

document.form.element.select() does it.

Thanks once again...

RI
 
R

Red_Indian

Mad said:
Does that help any?

Thanks a lot for that answer... especially for sparing the amount of time you did typing
that mail!

You were right... I looked around a bit and found a javascript function ".select" which
did the trick:

document.form.element.select() does it.

Thanks once again...

RI
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top