Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 27th, 2005, 06:24 AM
Authorized User
 
Join Date: Jul 2005
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>


 
Old July 27th, 2005, 05:21 PM
Friend of Wrox
 
Join Date: Jun 2003
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 ?
 
Old July 27th, 2005, 06:07 PM
Authorized User
 
Join Date: Jul 2005
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

 
Old July 29th, 2005, 10:12 AM
Authorized User
 
Join Date: Jul 2005
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






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





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