By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,566 Members | 1,779 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,566 IT Pros & Developers. It's quick & easy.

how to do rowspan and colspan with DOM

100+
P: 130
hello all,

i am trying to create a table useing dom and its going well but
was wondering how can i join rowa or join tbs

i can make this kind of table with no problam
_________
|..............|
---------------
|..............|
---------------
|..............|
---------------
|..............|
---------------
but how i can do it like this
__________________
| ..............|..............|
| ..............|..............|
|rowspan |--------------|
| ..............|..............|
| ..............|..............|
|------------------------------|
is there a way?
Oct 31 '07 #1
Share this Question
Share on Google+
3 Replies


dmjpro
100+
P: 2,476
How much you tried .... Please show me that code ....

Debasis
Oct 31 '07 #2

100+
P: 130
How much you tried .... Please show me that code ....

Debasis
lol, i posted this before so....
any way here is is :
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3.     document.getElementsByTagName("pre")[0].innerHTML ="";    //clear previues displays in the <pre>
  4.     var body = document.getElementsByTagName("pre")[0];         //put the table in <pre> here </pre>
  5.     var tbl  = document.createElement("table");                 //create table element
  6.     var tblBody = document.createElement("tbody");     
  7.  
  8.         for (var j = 0; j < 4; j++)                     //creating all cells
  9.         { 
  10.             var row = document.createElement("tr");         //creates a table row
  11.             row.setAttribute("height","39");                    //BTW cant control the higeht in  html?
  12.             for (var i = 0; i < 1; i++) 
  13.             {
  14.                 var cell = document.createElement("td");                        //Create a <td> element
  15.                 var linktd='<a href="www.google.com">google</a>';
  16.                 cell.innerHTML = linktd 
  17.                 cell.setAttribute("align","center");                            //set the aligen for the tdl    
  18.                 row.appendChild(cell);            //put the <td> at the end of the table row
  19.             }
  20.             tblBody.appendChild(row);                                 //add the row to the end of the table body
  21.         }
  22.     tblBody.appendChild(row);
  23.     tbl.appendChild(tblBody);
  24.  
  25.         tbl.appendChild(tblBody);                                    //put the <tbody> in the <table>
  26.         body.appendChild(tbl);                          // appends <table> into <body>
  27.         tbl.setAttribute("cellpadding","0");                                    // no cellpadding in the table
  28.         tbl.setAttribute("cellspacing","0");                                    // no cell spacing in the table
  29.         tbl.style.color = color_font;                                 //font color on the links
  30.         tbl.style.backgroundColor = bgcolor_r;                  //bgcolor for table
  31.         tbl.setAttribute("height",size_y_banner);
  32.         tbl.setAttribute("width",size_x_banner);
  33.         tbl.setAttribute("border",border_size1);            
  34. }
  35. </script>
hope u can help :)
Oct 31 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Use the rowSpan property.
Oct 31 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.