Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
98
rated 0 times [  104] [ 6]  / answers: 1 / hits: 20040  / 11 Years ago, thu, april 25, 2013, 12:00:00

I have a text box in my page:



<td>
<input type=text id=Approvers1 size=11 onkeydown=AddUsersKeyDown(event) style=width: 470px; />
</td>


This is my js function:



function AddUsersKeyDown(evtobj) {

if (evtobj.keyCode == 75 && evtobj.ctrlKey) {

AddUsers(--input parameter--);
}
}


Now if i press ctrl k in my textbox it must call another javascript function named AddUsers(--input parameter--).. where the input parameter should be the id of the textbox...



How to achieve this.. Either i need the id of the textbox or atleast the DOM object so that i can access the id of textbox from DOM object..



Kindly help me in achieving either one of the two things..


More From » asp.net

 Answers
7

Use this to get the DOM element or this.id to get the id of the element



<td>
<input type=text id=Approvers1 size=11 onkeydown=AddUsersKeyDown(event,this.id) style=width: 470px; />
</td>

function AddUsersKeyDown(evtobj,id) {

if (evtobj.keyCode == 75 && evtobj.ctrlKey) {

AddUsers(id);
}
}

[#78628] Wednesday, April 24, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
warren

Total Points: 679
Total Questions: 115
Total Answers: 78

Location: Antigua and Barbuda
Member since Sat, Apr 24, 2021
3 Years ago
;