janroald Posted February 14, 2006 Share Posted February 14, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/3422-insert-into-focused-textarea/ Share on other sites More sharing options...
Javizy Posted February 14, 2006 Share Posted February 14, 2006 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/3422-insert-into-focused-textarea/#findComment-11692 Share on other sites More sharing options...
janroald Posted February 14, 2006 Author Share Posted February 14, 2006 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/3422-insert-into-focused-textarea/#findComment-11694 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.