javascript - How to get the id of the textbox on keydown event of that textbox -
i have text box in page:
<td> <input type="text" id="approvers1" size="11" onkeydown="adduserskeydown(event)" style="width: 470px;" /> </td>
this js function:
function adduserskeydown(evtobj) { if (evtobj.keycode == 75 && evtobj.ctrlkey) { addusers(--input parameter--); } }
now if press ctrl k in textbox must call javascript function named addusers(--input parameter--).. input parameter should id of textbox...
how achieve this.. either need id of textbox or atleast dom object can access id of textbox dom object..
kindly me in achieving either 1 of 2 things..
use this
dom element or this.id
id of 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); } }