views:

19

answers:

1

Hi,

I wanted to know how I could find the previous active control on a page. I have a couple of textboxes and a button, and when i am on a certain textbox and I click the button, I want to highlight that textbox. I have the highlight functionality covered, but I don't know how to find out which textbox to run the function on...

Please help,

Thanks!

A: 

you'll have to keep track of it yourself you could try something like this:

var prev_el_id;

function focus_recorder(el)
{
    prev_el_id = el.id;
}

then on each element you want to track:

<input id='tb1' type='text' onfocus='focus_recorder(this)' ></input>

Then when you want to highlight the previous element you could just use the prev_el_id variable to find out which element it was.

luke