Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 27th, 2005, 06:24 AM
Authorized User
Join Date: Jul 2005
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts


I cannot figure out how to use javascript to complete the number of <td> missing on a table. Suppose that the last row on a table has 6 columns (tds) but the previous rows have less columns. Is it possible to dynamically create the missing tds with spaces in the previous rows?? Basically I need to generate the missing tds to align the table.

Also, I need to highlight the smallest value on each row in blue and the highest value on each row in red.

I would appreciate if someone could have a look at the table below and help me with the code.


        <table ID="Table1">
                        <table width="100%" id="tblStatistics" cellpadding="0" cellspacing="0" border="1">
                                <td>Variance Explained</td>
                                <td>Group 1</td>
                                <td>Group 2</td>
                                <td>Group 3</td>
                                <td>Group 4</td>
                                <td>Group 5</td>
                                <td>Group 6</td>
                                <td>6.6535 %</td>
                                <td>10.1040 %</td>
                                <td>12.4668 %</td>
                                <td>14.1525 %</td>
                                <td>16.0587 %</td>

Reply With Quote
  #2 (permalink)  
Old July 27th, 2005, 05:21 PM
Friend of Wrox
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post

It looks like you already know how many columns you have, why not simply put a space (&nbsp;) into the cells that you don't need and then have your code build it like that ?
Reply With Quote
  #3 (permalink)  
Old July 27th, 2005, 06:07 PM
Authorized User
Join Date: Jul 2005
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Greg,

I do not know how many columns I will have. This is just a mock up. I have to build the table dynamically and then onload I must run a javascript function to generate more tds as needed and to highlight the values as explained


Reply With Quote
  #4 (permalink)  
Old July 29th, 2005, 10:12 AM
Authorized User
Join Date: Jul 2005
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts

I tried to find some help online and I saw something that might help. However, the code was incomplete.

maxCells = 0
tbd = tblId.tBodies[0]
for(i=0; i<tbd.rows.length; i++)
  if(tbd.rows[i].cells.length > maxCells)
    maxCells = tbd.rows[i].cells.length

Any imput??



Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there some ':, missing ??? saban SQL Server ASP 1 May 28th, 2007 06:32 AM
What is missing? grstad SQL Language 11 March 6th, 2006 01:53 AM
Missing Code Alphonse BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 July 10th, 2005 08:10 AM
what am i missing? m002864 Crystal Reports 0 July 6th, 2004 07:24 AM
Missing sp_Accounts_GetPermissionDetails Dennis0656 BOOK: ASP.NET Website Programming Problem-Design-Solution 3 May 10th, 2004 10:07 AM

All times are GMT -4. The time now is 07:06 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.