A
Amir Hardon
I am dynamically adding rows to a table, and each row have a button which
removes it.
I have successfully implemented this for mozilla but I'm having troubles
with IE, here is how I did it:
Each new row's id is an index number, each button's name is the row's id,
and I'm adding this function as the click event listener for the button:
function removeline(event){
var row=document.getElementById("row" + event.target.name);
var tbody=document.getElementById("items");
var olds=tbody.style.display;
tbody.style.display="none";
tbody.removeChild(row);
tbody.style.display=olds;
}
I'm adding it this way:
var newbutton=document.createElement("INPUT");
newbutton.type="button";
newbutton.value="Remove";
newbutton.id=rowcount;
newbutton.name=rowcount;
if(navigator.userAgent.match("MSIE")) // for IE compatibility
newbutton.attachEvent("onclick",removeline);
else
newbutton.addEventListener("click",removeline,false);
But IE doesn't pass nothing as a parameter for removeline().
Any suggestions?
Thanks,
-Amir.
removes it.
I have successfully implemented this for mozilla but I'm having troubles
with IE, here is how I did it:
Each new row's id is an index number, each button's name is the row's id,
and I'm adding this function as the click event listener for the button:
function removeline(event){
var row=document.getElementById("row" + event.target.name);
var tbody=document.getElementById("items");
var olds=tbody.style.display;
tbody.style.display="none";
tbody.removeChild(row);
tbody.style.display=olds;
}
I'm adding it this way:
var newbutton=document.createElement("INPUT");
newbutton.type="button";
newbutton.value="Remove";
newbutton.id=rowcount;
newbutton.name=rowcount;
if(navigator.userAgent.match("MSIE")) // for IE compatibility
newbutton.attachEvent("onclick",removeline);
else
newbutton.addEventListener("click",removeline,false);
But IE doesn't pass nothing as a parameter for removeline().
Any suggestions?
Thanks,
-Amir.