Table inside a table

138 Views Asked by At

I've added a table inside a table.

enter image description here

 <tr>
    <td colspan="10">
      <table border="2" cellpadding="1" cellspacing="1">
          <tr>
              <td>col1 </td>
              <td>col2</td>
          </tr>
          <tr >
              <td >TEST </td>
              <td >33444</td>
          </tr>
          <tr >
             <td >TEST</td>
             <td >9900</td>
          </tr>
      </table>
    </td>
 </tr>

But I want "TEST" values under col1 and numeric values under col2. Currently all values are shown under col1.

Edit - Actual Code

 <tr>
    <td colspan="10">
      <table class='<%= "table"+count%>' style="display:none" border="2" cellpadding="1" cellspacing="1">
          <tr>
              <td>col1 </td>
              <td>col2</td>
          </tr>

           <nested:iterate property="equipC" id="equipmentFormBean" indexId="ffIndex" >
          <tr class='<%= "table"+count%> dataOff' style="display:none">
            <td align="right" ><nested:write property="equipInitial" /> </td>
            <td ><nested:write property="equipNum" /> </td>

          </tr>
          </nested:iterate>
      </table>
    </td>
 </tr>

How to do it?

3

There are 3 best solutions below

0
On

enter image description here

Use Google chrome...Your html code is right.On my PC I see the values are in COL2.

0
On

Use Forgot to use table heading heading tag "th"


<tr>
        <td colspan="10">
          <table border="2" cellpadding="1" cellspacing="1">
              <tr>
                  <th>col1 </th>
                  <th>col2</th>
              </tr>
              <tr >
                  <td >TEST </td>
                  <td >33444</td>
              </tr>
              <tr >
                 <td >TEST</td>
                 <td >9900</td>
              </tr>
          </table>
        </td>
     </tr>

0
On

Your HTML code is correct. With the html provided by you it displayed the tables properly. You may please see it here @ FIDDLE - http://jsfiddle.net/BRxKX/4986/

Problem could be with dynamic generation of tables and mostly around COLSPAN if at all its being used in your dynamic code.

Here is code that I tested (you can see this in - http://jsfiddle.net/BRxKX/4986/)

<html>
<head>

</head>
<body>
<table>
 <tr>
    <td colspan="10">
      <table border="2" cellpadding="1" cellspacing="1">
          <tr>
              <td>col1 </td>
              <td>col2</td>
          </tr>
          <tr >
              <td >TEST </td>
              <td >33444</td>
          </tr>
          <tr >
             <td >TEST</td>
             <td >9900</td>
          </tr>
      </table>
    </td>
 </tr>
</table>
</body>
</html>