autonumber table rows

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Any thoughts on automatically numbering the rows in an HTML table?

That is, a table has n rows and y columns, column 1 is "Index #".  As
the table is displayed by a browser column 1 holds sequential
incrementing numbers per row.

My server supports PHP and SSI.  I'd like to NOT do this with javascript.

Ed Mullen
I used to be clueless about math, but I turned that around 360 degrees.

Re: autonumber table rows

Quoted text here. Click to load it

Then do it with PHP, real easy. HTML won't do it, neither will CSS.

Re: autonumber table rows

rf wrote:

Quoted text here. Click to load it

Just a minor note on the last part: CSS will "do" this when implemented
according to the CSS 2.1 draft. You can use e.g.

table { counter-reset: line-number; }
th:first-child:before, td:first-child:before {
   content: counter(line-number) ".";
   counter-increment: line-number;
   padding-right: 0.3em; }

in order to add a row number and a period at the start of the first cell of
each row.

But since IE (even IE 7) does not support any of this, it's much better to
use server-side techniques for now.


Re: autonumber table rows

Jukka K. Korpela wrote:
Quoted text here. Click to load it

Thank you.  I'll give it a try and see how IE7 handles it (or doesn't).
  It's not a display issue, I'm just tired of manually counting the rows
in the table to tell people:  "Ok, now we have xx things in the list."
So, I don't care if IE displays it or not, only that IE doesn't screw
the whole layout because of it.

Ed Mullen
Nothing is foolproof to a sufficiently talented fool.

Re: autonumber table rows

Quoted text here. Click to load it

Note to self, must remember this little esotericity next time I am
trying to persuade someone of the idea that tables and lists are
conceptually related, even sometimes semantically equivalent.

<tr><td>Collect skirt from tailor</td></tr>
<tr><td>Take it to dry cleaner</td></tr>

<li>Collect skirt from tailor</li>
<li>Take it to dry cleaner</li>


Site Timeline