[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cgi-list
Subject:    Re: [CGI] Evenly distributing items in a HTML Table---HLP PLZ
From:       "Tony Lewis" <tlewis () exelana ! com>
Date:       2003-05-11 1:02:26
[Download RAW message or body]

Jann Linder wrote:


> Tony,
> 
> Thanks for the help...I have been knocking my head on the keyboard all
night
> over this.
> 
> Your situation works EXCEPT for things like:
> http://www.exelana.com/cgi-bin/test.cgi?5
> 1  3  5  NOTHING
> 2  4  NOTHING NOTHING
[snip]
> There is a pattern to where it will not work...but for the life of me I
> cannot figure out WHY?  Something to do with the ofllowing

Here's the explanation to the pattern: five items won't fit into one row of
four columns, but when you divide it into two rows, you don't need four
columns to populate it.

What layout do you want in that situation?

1  3  4  5
2  NOTHING NOTHING NOTHING

or

1  3  5
2  NOTHING  NOTHING

are possibilities.

> And ...i kinda need a solution that allows for a varible to control the
> columns too.  That may make  the solution more complicated.

The solution I submitted uses a variable for the number of columns. You can
recompute the variable after the number of rows has been computed as
follows:

my $nRows = int(($n+$nCols-1)/$nCols);
$nCols = int(($n+$nRows-1)/$nRows);

That changes the behavior to the second of the two possibilities that I
suggested earlier.

I went ahead and made that change. I also changed the behavior so the test
script tries values of 1 through 20 if no query string is specified.

Try http://www.exelana.com/cgi-bin/test.cgi and see if that is close to what
you want.

Tony

--
To unusbcribe, send an email contining the words: 'unsubscribe cgi-list' to the \
following email address: majordomo@jann.com

Archives of the following mailing lists are available at: http://www.perl.jann.com/
the CGI Mailing List
the mod_perl mailing list
the embperl mailing list
Searching, browsing and posting are available at http://www.perl.jann.com/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic