Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    wysiwyg - insert a table row

    I use this code to add a table in my iframe as rich text editor.

    Code:
    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" ?

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    Code:
    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
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •