Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

table.onclick isn't working for me for some reason

Posted on 2004-08-17
4
Medium Priority
?
177 Views
Last Modified: 2012-05-05
i can't get table.onclick to work.  i've tried these things...
table.onclick       = function() {return FTB_Exit('FreeTextBox1');};
table.onclick= FTB_Exit('FreeTextBox1');
table.onclick= FTB_Exit;
table.onclick= "FTB_Exit('FreeTextBox1');

heres the function

function FTB_CreateTable(ftbName,cols,rows,width,widthUnit,align,cellpadding,cellspacing,border) {
      var editor = FTB_GetIFrame(ftbName);
      editor.focus();
      var sel = FTB_GetSelection(ftbName);
      var range = FTB_CreateRange(ftbName,sel);      
      
      var doc = editor.document;
      // create the table element
      var table = doc.createElement("table");
      

      // assign the given arguments
      table.style.width       = width + widthUnit;
      table.align                   = align;
      table.border             = border;
      table.cellspacing       = cellspacing;
      table.cellpadding       = cellpadding;
      table.id            = "table" + tableId++;
      table.onclick       = function() {return FTB_Exit('FreeTextBox1');};
      
      var tbody = doc.createElement("tbody");
      table.appendChild(tbody);      

      for (var i = 0; i < rows; ++i) {
            var tr = doc.createElement("tr");
            tbody.appendChild(tr);
            for (var j = 0; j < cols; ++j) {
                  var td = doc.createElement("td");
                  tr.appendChild(td);
                  // Mozilla likes to see something inside the cell.
                  if (!isIE) td.appendChild(doc.createElement("br"));
            }
      }
      
      if (isIE) {
            range.pasteHTML(table.outerHTML);
      } else {
            FTB_InsertNodeAtSelection(ftbName,table);
      }
      
      return true;
}

any ideas??  oh and it either doesn't do anything or gives some error.  html not implemented i think
0
Comment
Question by:tricos1
  • 3
4 Comments
 
LVL 15

Expert Comment

by:Colosseo
ID: 11821503
Hi

have you tried

table.onclick= "return FTB_Exit('FreeTextBox1')";

what does FTB_Exit do anyway?

Regards

Scott
0
 
LVL 13

Expert Comment

by:davidlars99
ID: 11822003
i think the whole functio is wrong, here how I did mine a little while ago:


function makeOb(w,h,x,y,parent,txt,bgColor){
    var addTo=parent||document.getElementsByTagName("body").item(0);
    var obj=document.createElement('DIV');
    clip="";
    (h>-1)?clip="clip:rect(0px,"+w+"px,"+h+"px,0px);overflow:hidden;":'';
    obj.setAttribute("style","position:absolute;"+clip);
    obj.setAttribute("id","id"+windows.no);
    obj.innerHTML=txt+'\n';
    addTo.appendChild(obj);
    obj.style.position="absolute";
    obj.style.overflow="hidden";
    obj.style.left=x+"px";
    obj.style.top=y+"px";
      (w>-1)?obj.style.width=w+"px":'';
      (h>-1)?obj.style.height=h+"px":'';
      obj.style.clip="rect(0px,"+w+"px,"+h+"px,0px)";
      (bgColor)?obj.style.backgroundColor=bgColor:'';
    return document.getElementById("id"+windows.no++);

}


if you want to get it work use setAttributes like:

    obj.setAttribute("style","position:absolute;"+clip);
    obj.setAttribute("id","id"+windows.no);

and in the end define onclick event like this:

    document.getElementById("someid").onclick=.....




0
 
LVL 13

Expert Comment

by:davidlars99
ID: 11823073
if document.getElementById("someid").onclick=.....  won't work try other way

function eventAdder(objAttrib,handler,addFunction){
     
   if ((!document.all)&&(document.getElementById)){
       objAttrib.setAttribute(handler,addFunction);
   }    
   if ((document.all)&&(document.getElementById)){
       objAttrib[handler]=new Function(addFunction);
   }

}

and call this function from the inside FTB_CreateTable(...) (or in my example makeOb(...) ) like this:

eventAdder(objHTML,"onclick","dunebuggy()")




0
 
LVL 13

Accepted Solution

by:
davidlars99 earned 800 total points
ID: 11823485
if you want to pass argument in the function in the simple way try:

table.setAttribute("onclick", function(){  FTB_Exit('FreeTextBox1');  };

that's all
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question