Results 1 to 2 of 2

Thread: OnFocus

  1. #1
    Join Date
    Dec 1969

    Default OnFocus

    Please refer to http://www.aspmessageboard.com/forum/jscript.asp?M=432079&T=432079&F=29&P=1<BR><BR>I do not want a alert on everytime i set my focus but only when i click a button. Then i want to know where the previous onFocus is at...

  2. #2
    Join Date
    Dec 1969

    Default RE: OnFocus

    At the top of your page define a variable that will hold the last element that had focus:<BR><BR>&#060;script&#062;<BR>var lastfocus;<BR>&#060;/script&#062;<BR><BR>For each element that you&#039;re interested in add an onfocus event to it:<BR><BR>&#060;input type="text" name="whatever" onfocus="lastfocus=this"&#062;<BR><BR>You can then use lastfocus when a button is clicked:<BR><BR>&#060;input type="button" value="test" onclick="alert(&#039;The last element to have focus was &#039; + lastfocus.name)"&#062;<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts