Probably, you started programming very recently, but the problem is: JavaScript is in fact very hard to understand, despite the simplicity of typical application code.
Instead of passing the
id
, you can pass the control object itself. Let me show a simple example, with HTML and JavaScript only:
<html>
<head>
<script type="text/javascript">
function doSomethingWithTextBox(textBox) {
alert(textBox.value);
}
</script>
</head>
<body>
<input type="text" onkeydown="doSomethingWithTextBox(this)" />
<p>Some other text box:</p>
<input type="text" onkeydown="doSomethingWithTextBox(this)" />
</body>
</html>
As you can see, the required parameter is passed as "
this
" in the event declaration.
[EDIT]
And when you have different text boxes, the same handler will still distinguish them, because "
this
" object instances are different.
Problem solved!
—SA