Solved

problem in javascript

Posted on 2000-03-30
2
1,071 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 2670987
<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
ID: 2670997
... 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

726 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