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
Register
Register | FAQ | Members List | Calendar | 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
Reply
 
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
Default MISSING TDs

Hi,

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.

Cheers

<html>
    <head>
        <title></title>
    </head>
    <body>
        <table ID="Table1">
            <TBODY>
                <TR>
                    <TD>Test</TD>
                </TR>
                <TR>
                    <TD>
                        <table width="100%" id="tblStatistics" cellpadding="0" cellspacing="0" border="1">
                            <tr>
                                <td>Solution</td>
                                <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>
                            </tr>
                            <tr>
                                <td>2</td>
                                <td>6.6535 %</td>
                                <td>12504</td>
                                <td>11779</td>
                            </tr>
                            <tr>
                                <td>3</td>
                                <td>10.1040 %</td>
                                <td>9346</td>
                                <td>8952</td>
                                <td>5985</td>
                            </tr>
                            <tr>
                                <td>4</td>
                                <td>12.4668 %</td>
                                <td>7319</td>
                                <td>6552</td>
                                <td>5643</td>
                                <td>4769</td>
                            </tr>
                            <tr>
                                <td>5</td>
                                <td>14.1525 %</td>
                                <td>6199</td>
                                <td>5536</td>
                                <td>4238</td>
                                <td>4143</td>
                                <td>4167</td>
                            </tr>
                            <tr>
                                <td>6</td>
                                <td>16.0587 %</td>
                                <td>3503</td>
                                <td>4817</td>
                                <td>4852</td>
                                <td>3737</td>
                                <td>3849</td>
                                <td>3525</td>
                            </tr>
                        </table>
                    </TD>
                </TR>
            </TBODY>
        </table>
    </body>
</html>


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
Default

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
Default

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

Cheers

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
Default

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??

Cheers,

Claudio

Reply With Quote
Reply


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 02:47 AM.


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