Author Topic: Automatic table row numbering  (Read 16367 times)

Sang-drax

  • You created me, friend, you created me.
  • Jackass IV
  • Posts: 282
  • Karma: +10/-10
    • http://strandmark.com
Automatic table row numbering
« on: August 03, 2005, 04:27:17 AM »
Can I somehow number the rows in a table automatically?
 
Code: [Select]



[b]1.[/b] First entry Some data
[b]2.[/b] First entry Some data


 
Using
    is an option, but tables are much better.

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Automatic table row numbering
« Reply #1 on: August 03, 2005, 11:15:31 AM »
Code: [Select]


<%
for (int i = 0; i < MAX; i++) {
%>
   
<%
}
%>
<%= i %> Some Entry Some data




of course you'll need a tomcat installation for this to work... and you'll also have to name your file .jsp ;)

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Automatic table row numbering
« Reply #2 on: August 03, 2005, 11:41:06 AM »
eww... Try PHP:
Code: [Select]


for ($i = 0; $i < $MAX; $i++) {
?>
   
}
?>
Some Entry Some data



Of course you'll need to have PHP installed and name your file .php ;)

Ok, so they're not that much different.

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Automatic table row numbering
« Reply #3 on: August 03, 2005, 11:45:40 AM »
heh, they're almost exactly the same...

I think the point we're trying to make is you need to use some sort of technology for dynamic content if you don't want to use an
    .

Sang-drax

  • You created me, friend, you created me.
  • Jackass IV
  • Posts: 282
  • Karma: +10/-10
    • http://strandmark.com
Automatic table row numbering
« Reply #4 on: August 11, 2005, 02:11:03 PM »
OK, so it isn't possible with pure HTML/Style sheets? What about JavaScript? At the moment, PHP isn't available.

Sorry for my ignorance of this thread. :)

EDIT: I think I'll hack something together in JavaScript. It'll probably be ugly. I have a long list that I rearrange from time to time and I want a table instead to make it look nicer.

Sang-drax

  • You created me, friend, you created me.
  • Jackass IV
  • Posts: 282
  • Karma: +10/-10
    • http://strandmark.com
Automatic table row numbering
« Reply #5 on: August 11, 2005, 02:20:12 PM »
Thinking of Duff's device, I tried this:

 
Code: [Select]




  1. Petter
  2. Strandmark
  3. Petter2
  4. Strandmark2

  5. Item3
  6. Item4

It gave different results in IE and Firefox -- none of them "correct".

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Automatic table row numbering
« Reply #6 on: August 11, 2005, 06:49:24 PM »
Your best bet is probably JS if the others aren't available.

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Automatic table row numbering
« Reply #7 on: August 11, 2005, 09:52:04 PM »
something so you can re-order without renumbering?

like this? (working from memory, no syntax guarentees)
Code: [Select]

index = 1;
function next(entry, data) {
  return "" + (index++) + ". " + entry + "" + data + "";
}

function populate() {
  document.write("");
  document.write(next("some entry", "some data"));
  document.write(next("some entry1", "some data1"));
  document.write(next("some entry2", "some data2"));
  document.write(next("some entry3", "some data3"));

....

  document.write("
");
}

Sang-drax

  • You created me, friend, you created me.
  • Jackass IV
  • Posts: 282
  • Karma: +10/-10
    • http://strandmark.com
Automatic table row numbering
« Reply #8 on: August 12, 2005, 11:45:01 AM »
Thanks, but I'll probably encapsulate the document.write call in the 'next' function. :)

Is it common to browse the web with JS disabled?

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Automatic table row numbering
« Reply #9 on: August 12, 2005, 01:07:25 PM »
A fair amount of people do... but I tend to ignore that fact most of the time :(

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Automatic table row numbering
« Reply #10 on: August 12, 2005, 01:50:18 PM »
just have a "noscript" option without numbers?

Sang-drax

  • You created me, friend, you created me.
  • Jackass IV
  • Posts: 282
  • Karma: +10/-10
    • http://strandmark.com
Automatic table row numbering
« Reply #11 on: August 12, 2005, 04:48:39 PM »
Quote from: Perspective
just have a "noscript" option without numbers?

I could do:
Code: [Select]






I suspect that even if browers have script turned off, they will still ignore anything within
Title Description
Title Description