...

View Full Version : wysiwyg - insert a table row



baluba
02-17-2007, 10:17 AM
I use this code to add a table in my iframe as rich text editor.



function insertTable(rows, columns, border, cellpadding, cellspacing) {
var html="";
html += '<table width="100%" border="'+border+'" cellspacing="'+cellspacing+'" cellpadding="'+cellpadding+'">';
html += '<tbody>';
for(var j = 0; j < rows; j++) {
html += "<tr>";
var width = 100/columns;
for(var i = 0; i < columns; i++) {
html += "<td valign=\"top\" width=\""+width+"%\"></td>";
}
html += "</tr>";
}
html += "</tbody>";
html += "</table>";

sml(html);

this.close();
}

function sml(code){
if (opener.document.frames("Composition").document.selection && opener.document.frames("Composition").document.selection.createRange()) {
opener.document.frames("Composition").document.focus();
var sel=opener.document.frames("Composition").document.selection;
var rng=sel.createRange();
rng.pasteHTML(code);
}
}



How can I add new rows to this table clicking the icon "Add new row" ?

vwphillips
02-17-2007, 12:52 PM
function zxcIFObjSelection(){
if (zxcIE){ return zxcIFObj.contentWindow.document.selection.createRange().htmlText; }
return zxcIFObj.contentWindow.getSelection().getRangeAt(0);
}


returns the selected text
do what you will with it and replace the selected text



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum