Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

table columns

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
I must display a series of numbers in a table. Normally, we place table cells in table rows. This means that the values will print from left to right. I must display my values in an up-down pattern.

For example, a typical table might look like this...

first cell second cell third cell
fourth cell

My table must look like this...

first cell fourth cell
second cell
third cell

So instead of the table row tag ("<tr>"), I need a hypothetical table column tag ("<tc>"). I imagine that such a tag must exist, but I don't remember seeing it previously. How should I proceed?
 
There is no "tc" tag (or anything similar to do what you want).

Are you looking to generate this table from some server-side code? If so, then you can just code around it serverside... it doesn't matter the "order" of the cells in the actual source code... it's the final output on the screen that is important, surely.

You ask how you should proceed... I would suggest using a normal table, and instead of making it 3 columns, 2 rows, make it 2 columns, 3 rows (as in your example).

I don't see the problem. Maybe there *is* a problem... and I just haven't seen it.

Jeff
 
you may want to look at this sample table:


Code:
<table>

<td>1</td>
<td>2</td>
<td>3</td>
  <tr>
    <td>4</td>
    <td>5</td>
    <td>6</td>
  </tr>
<td>7</td>
<td>8</td>
<td>9</td>
</table>
[code]

hope that helps.

VJ
 
I meant :

Code:
<table>

<td>1</td>
<td>2</td>
<td>3</td>
  <tr>
    <td>4</td>
    <td>5</td>
    <td>6</td>
  </tr>
<td>7</td>
<td>8</td>
<td>9</td>
</table>

-VJ
 
If the values you're using to populate the table are in an array and you know how many rows max you want in your table, then you can populate your table from left to right just using some simple logic in javascript.

Here's an example I got to work in IE6:

Code:
<html>
<head>
</head>
<body>
<table>
<script>
var MAXROWS = 3; [b]//for example[/b]
var arrayLength = 10; [b]//you would use arrayName.length[/b]
var numRows = Math.floor(arrayLength/MAXROWS); 

for(var i=0; i<numRows; i++)
{
 document.write("<tr>");
 for(var j=0; j<arrayLength; j+= numRows)
 {
  if(i+j < arrayLength)
   document.write("<td>"+(i+j)+"</td>");
[b]//your line: document.write("<td>"+arrayName[i+j]+"</td>");[/b]
  else
   document.write("<td>&nbsp;</td>");
 }//end for
}//end for
</script>
</table>
</body>
</html>

Run the example to prove to yourself it works (you'll just see the index numbers appear in a top-down fashion the way you describe) then change the code as indicated in the comments to include the actual array you've got.

Naturally, if you DON'T have your table contents in an array already, then to do this, you will have to put them in one.

'hope this helps.

--Dave
 
Amorous, your table displays values in the traditional way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top