Jump to content


Photo

Insert into focused textarea


  • Please log in to reply
2 replies to this topic

#1 janroald

janroald
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts
  • LocationTrondheim, Norway

Posted 14 February 2006 - 09:55 AM

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?

#2 Javizy

Javizy
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 14 February 2006 - 11:23 AM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Use onfocus to track the current focus:
the events onfocus and onblur 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.

#3 janroald

janroald
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts
  • LocationTrondheim, Norway

Posted 14 February 2006 - 12:19 PM

[!--quoteo(post=345613:date=Feb 14 2006, 12:23 PM:name=Javizy)--][div class=\'quotetop\']QUOTE(Javizy @ Feb 14 2006, 12:23 PM) View Post[/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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users