I have a javascript function that gathers a list of modules the user can add to their view. After I have the list, I build a hidden table that be pulled up later to click and add modules to their view. In that function, it loops through and builds the table. That part works fine.
I’m having issues with adding the onclick event. My code for this so far:
[CODE]
if(td.addEventListener)
{
td.addEventListener(“click”, function(){addModule(this.id.replace(“newmoduletd”, “”));}, false);
}
else
{
td.attachEvent(“onclick”, function(){addModule(this.id);});
}
In firefox, the first function works great. In IE, ‘this’ shows as an object (the addModule function is just an alert on the parameter, at the moment). However, this.id, this.nodeType, etc are all showing as undefined.
My goal is to pass the numerical portion embedded in the td’s id. In the loop portion before this block of code, I have a variable with the id that I can also use, but when I try passing that through, it doesn’t ‘remember’ things well. If I pass using the array directly (data[j][‘id’]), j is out of bounds by the time I use the click. If I set the value to a local variable then pass it through, it only remembers the last one set. I need to somehow loop through and get unique id values passed to each event handler call.