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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table Column

Status
Not open for further replies.

joestone

Programmer
Aug 5, 2003
2
US
Can anyone tell me how to reference a table column in a document statement? If I have a table with 5 columns, how can I just work with column 3?

document.myform.column3???

Looping thru the rows doesn't work for me. I have checked out <colgroup> and <col>. I can't get them to work, perhaps I am not referencing them correctly.
 
I'm not sure if there's an easier way to do this, but you can try something like this:

<tr>
<td name='col1'>a1</td>
<td name='col2'>a2</td>
<td name='col3'>a3</td>
</tr>

<tr>
<td name='col1'>b1</td>
<td name='col2'>b2</td>
<td name='col3'>b3</td>
</tr>

<tr>
<td name='col1'>c1</td>
<td name='col2'>c2</td>
<td name='col3'>c3</td>
</tr>

...etc

to reference all the elements in a column you could write a javascript function like so:
Code:
function manipulateColumns(num) {
   eval(&quot;arr = formName.col&quot; + num);
   for(var i = 0; i < arr.length; i++) {
      if(arr[i].checked) {
         //whatever you want to do to the column
      }
   }
}

Note I've done absolutely no research on manipulating tables a column at a time, so there might be a better way to do this. But this should work.

-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top