Link to home
Start Free TrialLog in
Avatar of narrav
narrav

asked on

problem in javascript

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
Avatar of knightEknight
knightEknight
Flag of United States of America image

<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 );
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial