Rajasekar
Rajasekar

Reputation: 18968

How to set the id for a set of <tr>s in a table

I'm having a table with tr generating in a loop

<table>
    <div id="trresults">
    {FOR LOOP}
         <tr>
             <td>sample text</td>
             <td>sample text</td>
             <td>sample text</td>
         </tr>
         <tr>
             <td>sample text</td>
             <td>sample text</td>
             <td>sample text</td>
         </tr>
    {END FOR LOOP}
     </div>
</table>

I want to group the tr's and set a id for that. So that I used div for that, but div will not work as in table all the items should be inside td's. So how can I solve this problem?

Upvotes: 1

Views: 4723

Answers (1)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 299068

You can use a TBODY element to group your rows

<table>
    <tbody id="trresults1">
      {FOR LOOP}
         <tr><td>for loop message</td></tr>
      {END FOR LOOP}
     </tbody>
    <tbody id="trresults2">
      {FOR LOOP}
         <tr><td>for loop message</td></tr>
      {END FOR LOOP}
     </tbody>
</table>

Reference: Mozilla HTML Reference

Upvotes: 6

Related Questions