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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dynamic table rows using JSON

    Hi All,
    I want the logic to generate the table and add the rows dynamically in the div using JSON. This div should be displayed when I do right click on the link in my web application (My requirement is just like contextual tagging)

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Well if you look at sites like codingforums.com or dynamidrive.com, there are right click contextual menus that you can play with. Just remember that people can turn off right click at the browser level and people do like to use right click for navigation, copy/paste, etc.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New to the CF scene
    Join Date
    Feb 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    contextual menu

    I tried to create dynamic table and I want that table to be displayed when I do right click on the link as a popup.

    I used setCapture() for right click. and also i didnt get the logic anywhere for this.

    I want to get that table to be displayed as a popup

    the code, which I have written to generate the table is as follows:

    function createDynTable(row, col)
    {
    oContextMenu.innerHTML="";
    //oContextObject=oTarget;
    iMenuItems=0;
    oContextMenu.setCapture();
    // get the reference for the body
    var mybody = document.getElementsByTagName("body")[0];
    var mydiv = document.createElement("div");

    // creates a <table> element and a <tbody> element
    mytable = document.createElement("table");
    mytablebody = document.createElement("tbody");

    // creating all cells
    for(var j = 0; j < row; j++) {
    // creates a <tr> element
    mycurrent_row = document.createElement("tr");
    for(var i = 0; i < col; i++) {
    // creates a <td> element
    mycurrent_cell = document.createElement("td");

    // add edit cell;
    mycurrent_cell.ondblclick = function (evt) { editCell(this);};

    // creates a text node
    currenttext = document.createTextNode("cell is row "+j+", column "+i);
    // appends the text node we created into the cell <td>
    mycurrent_cell.appendChild(currenttext);
    // appends the cell <td> into the row <tr>
    mycurrent_row.appendChild(mycurrent_cell);
    }
    // appends the row <tr> into <tbody>
    mytablebody.appendChild(mycurrent_row);

    }
    // appends <tbody> into <table>
    mytable.appendChild(mytablebody);
    mydiv.appendChild(mytable);
    // appends <table> into <body>
    mybody.appendChild(mytable);
    // sets the border attribute of mytable to 2;
    mytable.setAttribute("border", "2");

    //return mytable;
    oContextMenu.innerHTML=mytable;
    iMenuItems++;
    }

    Thanks
    Visala


  •  

    Posting Permissions

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