Jump to content

Archived

This topic is now archived and is closed to further replies.

janroald

Insert into focused textarea

Recommended Posts

I want to insert text into a currently focused/active textarea without referring to id or looping through the elements. Simply insert into the textarea that currently has the "text-blinker" in it.

Anyone?

Share this post


Link to post
Share on other sites
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--][b]Use onfocus to track the current focus:[/b]
the events [i]onfocus[/i] and [i]onblur[/i] can now be used with every element. There is no standard DOM interface to get the current document focus, so if you want to track that you'll have to keep track of it in a JS variable. [/quote]

Taken from [a href=\"http://www.mozilla.org/access/keyboard/tabindex\" target=\"_blank\"]mozilla site[/a]

So if you're already setting a function for the onfocus event for the textareas, add a function call that stores the id in a variable, and then use this in a getElementById in your insert function.

Share this post


Link to post
Share on other sites
[!--quoteo(post=345613:date=Feb 14 2006, 12:23 PM:name=Javizy)--][div class=\'quotetop\']QUOTE(Javizy @ Feb 14 2006, 12:23 PM) [snapback]345613[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Taken from [a href=\"http://www.mozilla.org/access/keyboard/tabindex\" target=\"_blank\"]mozilla site[/a]

So if you're already setting a function for the onfocus event for the textareas, add a function call that stores the id in a variable, and then use this in a getElementById in your insert function.
[/quote]

Nice. Why didn't I think of that... Easy and good solution!

Thx man.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.