Posted by: Veer Gorkhali June 11, 2008
Need help in Java Script and JSP
Login in to Rate this Post:     0       ?        
CIGG this his what my .js file looks like this. And help me in this code. Thanks.

    function d2_thumbnail_table()
    {
        // get the reference for the body
        var body = document.getElementsByTagName("body")[0];

        //default values for each cell
        var DEFAULT_WIDTH = 70;
        var DEFAULT_HEIGHT = 70;  
        var DEFAULT_ROW = 7;
        var DEFAULT_COLUMN = 10;

        // creates a <table> element and a <tbody> element
        var tbl     = document.createElement("table");
        var tblBody = document.createElement("tbody");
       
        // creating all cells
        for (var i = 0; i < DEFAULT_ROW; i++) {
            // creates a table row
            var row = document.createElement("tr");
                    
            for (var j = 0; j < DEFAULT_COLUMN; j++) {
               
                // Create a <td> element
                var cell = document.createElement("td");
                cell.height = DEFAULT_HEIGHT;
                cell.width = DEFAULT_WIDTH;
              
                var cellText = document.createTextNode("Row "+i+", Column "+j);
                //var cellImage = "<img src='images/small_2d_images/001.jpg'>";

                cell.appendChild(cellText);
              
                cell.style.background = "rgb(50,250,50)";
                //cell.style.background = "<img src=\"images/small_2d_images/001.jpg\">";
               
                row.appendChild(cell);               
            }

            // add the row to the end of the table body
            tblBody.appendChild(row);
        }

        // put the <tbody> in the <table>
        tbl.appendChild(tblBody);
        // appends <table> into <body>
        body.appendChild(tbl);
        // sets the border attribute of tbl to 1;
        tbl.setAttribute("border", "1");
    }
Read Full Discussion Thread for this article