Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have a multiple TextBoxes in a page.
Tab-key is using to navigate from one TextBox to other TextBox .
when user press tab-key I need to get the the ID the TextBox (in javascript) in which the cursor exist.

I can get the Tab-key press event.
But How can I get the Textbox-ID(where cursor is) on Tab-key press.
Can anyone help me to resolve this?
Posted

Hi SHAJANCHERIAN,

I think no need to get Textbox id. you can sent the text box object directly to your function.
for example:
JavaScript
<script type="text/javascript">
function gettextboxobject()
{

}
</script>

<input type="text" id="textbox1" onblur="gettextboxobject(this)"  önfocus="gettextboxobject(this)" />

you can get the textbox object directly.

please reply if you want more.
 
Share this answer
 
v2
Comments
Mohibur Rashid 17-Sep-12 20:11pm    
he does not need more, its exactly what he need
SHAJANCHERIAN 18-Sep-12 0:33am    
Thank you so much. this is helpful to solve my problem. Actually I wanted to save the data from the text-box (ie. last-focused) in to a global variable for further use.
You can try taking a look at DOM Element document.activeElement. As far as I remember, it doesn't work consistently across browsers, but it should get you started.

From here on, Google[^] is your friend. I'm sure you'll find something to help you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900