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

Html table not proper in print preview

P: 3
Hi,
I have a html page where in the table spans for two pages
the first page's last row doesn end properly and the 2nd page's first row also isnt proper.The code i use is given below,the no of pages the table will spread over is dyanmically decided,

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <style>
  4.  
  5. tHead
  6. {
  7.   display : table-header-group;
  8. }
  9.  
  10.  
  11. </style>
  12. </head>
  13. <script>
  14.  
  15. function AddTHEAD(tableName)
  16. {
  17.    var table = document.getElementById(tableName); 
  18.    if(table != null) 
  19.    {
  20.     var head = document.createElement("THEAD");
  21.     head.style.display = "table-header-group";
  22.     head.appendChild(table.rows[0]);
  23.     table.insertBefore(head, table.childNodes[0]); 
  24.    }
  25.  
  26. }
  27. </script>
  28. <body onload="javascript: AddTHEAD('DataGrid')">
  29.  
  30. <table border="1" id="DataGrid">
  31.  
  32. <tr>
  33. <th>Heading</th>
  34. <th>Another Heading</th>
  35. </tr>
  36.  
  37. <tr>
  38. <td>row 1, cell 1</td>
  39. <td>row 1, cell 2</td>
  40. </tr>
  41. <tr>
  42. <td>row 2, cell 1</td>
  43. <td>row 2, cell 2</td>
  44. </tr>
  45. <tr>
  46. <td>row 2, cell 1</td>
  47. <td>row 2, cell 2</td>
  48.  
  49. </tr>
  50. <tr>
  51. <td>row 2, cell 1</td>
  52. <td>row 2, cell 2</td>
  53. </tr>
  54. <tr>
  55. <td>row 2, cell 1</td>
  56. <td>row 2, cell 2</td>
  57. </tr>
  58. <tr>
  59. <td>row 2, cell 1</td>
  60. <td>row 2, cell 2</td>
  61.  
  62. </tr>
  63. <tr>
  64. <td>row 2, cell 1</td>
  65. <td>row 2, cell 2</td>
  66. </tr>
  67. <tr>
  68. <td>row 2, cell 1</td>
  69. <td>row 2, cell 2</td>
  70. </tr>
  71. <tr>
  72. <td>row 2, cell 1</td>
  73. <td>row 2, cell 2</td>
  74.  
  75. </tr>
  76. <tr>
  77. <td>row 2, cell 1</td>
  78. <td>row 2, cell 2</td>
  79. </tr>
  80. <tr>
  81. <td>row 2, cell 1</td>
  82. <td>row 2, cell 2</td>
  83. </tr>
  84. <tr>
  85. <td>row 2, cell 1</td>
  86. <td>row 2, cell 2</td>
  87.  
  88. </tr>
  89. <tr>
  90. <td>row 2, cell 1</td>
  91. <td>row 2, cell 2</td>
  92. </tr>
  93. <tr>
  94. <td>row 2, cell 1</td>
  95. <td>row 2, cell 2</td>
  96. </tr>
  97. <tr>
  98. <td>row 2, cell 1</td>
  99. <td>row 2, cell 2</td>
  100.  
  101. </tr>
  102. <tr>
  103. <td>row 2, cell 1</td>
  104. <td>row 2, cell 2</td>
  105. </tr>
  106. <tr>
  107. <td>row 2, cell 1</td>
  108. <td>row 2, cell 2</td>
  109. </tr>
  110. <tr>
  111. <td>row 2, cell 1</td>
  112. <td>row 2, cell 2</td>
  113.  
  114. </tr>
  115. <tr>
  116. <td>row 2, cell 1</td>
  117. <td>row 2, cell 2</td>
  118. </tr>
  119. <tr>
  120. <td>row 2, cell 1</td>
  121. <td>row 2, cell 2</td>
  122. </tr>
  123. <tr>
  124. <td>row 2, cell 1</td>
  125. <td>row 2, cell 2</td>
  126.  
  127. </tr>
  128. <tr>
  129. <td>row 2, cell 1</td>
  130. <td>row 2, cell 2</td>
  131. </tr>
  132. <tr>
  133. <td>row 2, cell 1</td>
  134. <td>row 2, cell 2</td>
  135. </tr>
  136. <tr>
  137. <td>row 2, cell 1</td>
  138. <td>row 2, cell 2</td>
  139.  
  140. </tr>
  141. <tr>
  142. <td>row 2, cell 1</td>
  143. <td>row 2, cell 2</td>
  144. </tr>
  145. <tr>
  146. <td>row 2, cell 1</td>
  147. <td>row 2, cell 2</td>
  148. </tr>
  149. <tr>
  150. <td>row 2, cell 1</td>
  151. <td>row 2, cell 2</td>
  152.  
  153. </tr>
  154. <tr>
  155. <td>row 2, cell 1</td>
  156. <td>row 2, cell 2</td>
  157. </tr>
  158. <tr>
  159. <td>row 2, cell 1</td>
  160. <td>row 2, cell 2</td>
  161. </tr>
  162. <tr>
  163. <td>row 2, cell 1</td>
  164. <td>row 2, cell 2</td>
  165.  
  166. </tr>
  167. <tr>
  168. <td>row 2, cell 1</td>
  169. <td>row 2, cell 2</td>
  170. </tr>
  171. <tr>
  172. <td>row 2, cell 1</td>
  173. <td>row 2, cell 2</td>
  174. </tr>
  175. <tr>
  176. <td>row 2, cell 1</td>
  177. <td>row 2, cell 2</td>
  178.  
  179. </tr>
  180. <tr>
  181. <td>row 2, cell 1</td>
  182. <td>row 2, cell 2</td>
  183. </tr>
  184. <tr>
  185. <td>row 2, cell 1</td>
  186. <td>row 2, cell 2</td>
  187. </tr>
  188. <tr>
  189. <td>row 2, cell 1</td>
  190. <td>row 2, cell 2</td>
  191.  
  192. </tr>
  193. <tr>
  194. <td>row 2, cell 1</td>
  195. <td>row 2, cell 2</td>
  196. </tr>
  197. <tr>
  198. <td>row 2, cell 1</td>
  199. <td>row 2, cell 2</td>
  200. </tr>
  201. <tr>
  202. <td>row 2, cell 1</td>
  203. <td>row 2, cell 2</td>
  204.  
  205. </tr>
  206. <tr>
  207. <td>row 2, cell 1</td>
  208. <td>row 2, cell 2</td>
  209. </tr>
  210. <tr>
  211. <td>row 2, cell 1</td>
  212. <td>row 2, cell 2</td>
  213. </tr>
  214. <tr>
  215. <td>row 2, cell 1</td>
  216. <td>row 2, cell 2</td>
  217.  
  218. </tr>
  219. <tr>
  220. <td>row 2, cell 1</td>
  221. <td>row 2, cell 2</td>
  222. </tr>
  223. <tr>
  224. <td>row 2, cell 1</td>
  225. <td>row 2, cell 2</td>
  226. </tr>
  227. <tr>
  228. <td>row 2, cell 1</td>
  229. <td>row 2, cell 2</td>
  230.  
  231. </tr>
  232. <tr>
  233. <td>row 2, cell 1</td>
  234. <td>row 2, cell 2</td>
  235. </tr>
  236. <tr>
  237. <td>row 2, cell 1</td>
  238. <td>row 2, cell 2</td>
  239. </tr>
  240. <tr>
  241. <td>row 2, cell 1</td>
  242. <td>row 2, cell 2</td>
  243.  
  244. </tr>
  245. <tr>
  246. <td>row 2, cell 1</td>
  247. <td>row 2, cell 2</td>
  248. </tr>
  249. <tr>
  250. <td>row 2, cell 1</td>
  251. <td>row 2, cell 2</td>
  252. </tr>
  253. <tr>
  254. <td>row 2, cell 1</td>
  255. <td>row 2, cell 2</td>
  256.  
  257. </tr>
  258. <tr>
  259. <td>row 2, cell 1</td>
  260. <td>row 2, cell 2</td>
  261. </tr>
  262.  
  263.  
  264.  
  265. </table>
  266. </body>
  267. </html>

Thanks
Albin
Mar 28 '08 #1
Share this Question
Share on Google+
2 Replies


Computer Guru
P: 16
Honestly I can't find anything wrong with it. It may look a little awkward at the end of the page but it is not very noticeable. If you are really having problems with it, I suggest putting a page break before the table or making two tables. I can't seem to recreate your error. If your page is published you could post the link and I could take a look at it else you're on your own.

Computer Guru
Jun 26 '08 #2

eWish
Expert 100+
P: 971
Must be an IE issue. I am looking at it in FireFox 3 and no problems. I looked at it in IE and it does have issues. Here is an article that may help you with this.

--Kevin
Jun 26 '08 #3

Post your reply

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