I try to write a plugin to set custom cell attributes and can't figure out how to set a cell attribute.
I tried the function SetAttribute() which does nothing and the methods setAttribute[NS]() gives me a DOM Error.
Any recommendations?
--
var aCells = oEditor.FCKTableHandler.GetSelectedCells();
var chk = document.getElementsByName('attName');
for(var i=0; i<aCells.length; i++){
for(var j=0; j<chk.length; j++){
if(chk[j].checked){
var attname=chk[j].value;
var attvalue=document.getElementsByName(attname)[0].value;
SetAttribute(aCells[i], attname, attvalue);
if(document.all){
alert("Insert for IE");
aCells[i].setAttribute(attname,attvalue,0);
}else{
alert("Insert for NS");
aCells[i].setAttributeNS(null,attname,attvalue);
}
}
}
--
I tried the function SetAttribute() which does nothing and the methods setAttribute[NS]() gives me a DOM Error.
Any recommendations?
--
var aCells = oEditor.FCKTableHandler.GetSelectedCells();
var chk = document.getElementsByName('attName');
for(var i=0; i<aCells.length; i++){
for(var j=0; j<chk.length; j++){
if(chk[j].checked){
var attname=chk[j].value;
var attvalue=document.getElementsByName(attname)[0].value;
SetAttribute(aCells[i], attname, attvalue);
if(document.all){
alert("Insert for IE");
aCells[i].setAttribute(attname,attvalue,0);
}else{
alert("Insert for NS");
aCells[i].setAttributeNS(null,attname,attvalue);
}
}
}
--
RE: Plugin: Custom td attribute
And SetAttribute is calling setAttribute so it isn't neccesary that last part.
Check that the cells are valid objects, and the values that you pass to the functions are strings.