Solved

problem in javascript

Posted on 2000-03-30
2
1,070 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

856 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