J
Jason
Hello,
I am trying to dynamically create a table, then set its <td>'s onclick:
var table = document.createElement("table");
var row = table.insertRow(-1);
var td = row.insertCell(-1);
td.onclick = myfunction;
function myfunction(event) {
alert(event);
}
For some reason I cant get this to work. I have tried:
- td.setAttribute("onclick", myfunction);
- Event.observe(td, 'click', myfunction, false);
None of them will register the onclick event properly. Either td will
have _extended="true" as an attribute, or event will be "undefined" in
myfunction. This is only a problem in IE. Does anyone know how to fix
this problem?
- Jason
I am trying to dynamically create a table, then set its <td>'s onclick:
var table = document.createElement("table");
var row = table.insertRow(-1);
var td = row.insertCell(-1);
td.onclick = myfunction;
function myfunction(event) {
alert(event);
}
For some reason I cant get this to work. I have tried:
- td.setAttribute("onclick", myfunction);
- Event.observe(td, 'click', myfunction, false);
None of them will register the onclick event properly. Either td will
have _extended="true" as an attribute, or event will be "undefined" in
myfunction. This is only a problem in IE. Does anyone know how to fix
this problem?
- Jason