c# - Get the ID of the dynamically generated textbox which is calling a javascript function -



c# - Get the ID of the dynamically generated textbox which is calling a javascript function -

i dynamically generating textboxes in asp page , suppose calling javascript function "foo" on text change. want pass textbox id calling function javascript function.

i.e. if typing in textbox 3, wanna show typing in txtbox3 (the id of textbox 3)

i have autocomplete function dont know how pass id of calling textbox.. using class attribute changes value of every textbox... want id instead of .tbi

there couple answers depend upon how code works.

if attaching event handler addeventlistener, can object generated event this pointer this:

obj.addeventlistener("change", function() { // id of object triggered event var id = this.id; // whatever want id }, false)

or using regular function:

function foo(e) { // id of object triggered event var id = this.id; // whatever want id } obj.addeventlistener("change", foo, false);

or, if embedding event handler straight in html, can this:

<textarea id="xxx" onchange="foo(this)"></textarea> function foo(obj) { // id of object triggered event var id = obj.id; // whatever want id }

as case on stackoverflow, if show actual html , javascript, answers specific particular situation.

c# javascript asp.net dynamic

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -