Solved

problem in javascript

Posted on 2000-03-30
2
1,067 Views
Last Modified: 2012-06-27
Hey all,
may be somebody can help me with this..
Just have 3 textboxes...


<FORM name='myform' action='#'>
 <INPUT type='text' name='month' size='10' maxlength='10'>
 <INPUT type='text' name='day' size='10' maxlength='10' >
 <INPUT type='text' name='year' size='10' maxlength='10'>
</form>

I am trying to find a way to know which element has my focus --  in javascript..

is there anything like   isfocus   in javascript...???

help me with this pls..

regards
0
Comment
Question by:narrav
  • 2
2 Comments
 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
<SCRIPT language='javascript'>
 var isfocused = null;
</script>


<FORM name='myform' action='#'>
 <INPUT type='text' name='month' size='10' maxlength='10' onFocus='isfocused=this;'>
 <INPUT type='text' name='day' size='10' maxlength='10'  onFocus='isfocused=this;'>
 <INPUT type='text' name='year' size='10' maxlength='10'  onFocus='isfocused=this;'>
</form>


now at any time you wish to know which element has focus, simply do this:

if ( isfocused )
  alert( isfocused.name );
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 80 total points
Comment Utility
... ok, a bad example maybe because as soon as you do the "alert" above, the focus is removed from the element and put on the alert box instead.  :>0   But the idea is the same, the "isfocused" variable will point to the form element that most recently received focus.  :)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now