...

View Full Version : dynamic table rows using JSON



visala
05-05-2008, 09:43 AM
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)

A1ien51
05-05-2008, 02:32 PM
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

visala
05-05-2008, 04:03 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum