CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2006
    Posts
    62

    CSS: Cannot Hide Table

    Hey, for some reason I cannot hide a table and its contents inside. This can hide text and things out of the table but other than that it does nothing. I can't figure out why, what's wrong?

    Code:
    <div id="test" style="display:none">
          <tr>
                      
                 <td width="60" height="47">Price:</td>
                 <td width="110"><input type="text" size="8" maxlength="8" name="Price"/></td>
                          
          </tr>
    </div>
    Thanks

  2. #2
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    Re: CSS: Cannot Hide Table

    Quote Originally Posted by Tanner8
    Hey, for some reason I cannot hide a table and its contents inside. This can hide text and things out of the table but other than that it does nothing. I can't figure out why, what's wrong?
    Thanks
    Well, the two sets of code (below) work absolutely fine as they are, so I guess you've got some inheritence problem...
    Do you have a style section or a linked CSS? If so, is there anything relevent in there?


    Code:
    <div id="test" style="display: none;">
      <table><tbody>
    	<tr>
    	  <td style="width: 60px; height: 47px;">Number:</td>
    	  <td style="width: 110px;"><input type="text" size="8" maxlength="2" name="Price"></td>
    	</tr>
    	<tr>
    	  <td width="60" height="47">Price:</td>
    	  <td width="110"><input type="text" size="8" maxlength="8" name="Price"/></td>
    	</tr>
      </tbody></table>
    </div>
    Code:
    <div>
      <table><tbody>
    	<tr>
    	  <td style="width: 60px; height: 47px;">Number:</td>
    	  <td style="width: 110px;"><input type="text" size="8" maxlength="2" name="Price"></td>
    	</tr>
    	<tr id="test" style="display: none;">
    	  <td style="width: 60px; height: 47px;">Price:</td>
    	  <td style="width: 110px;"><input type="text" size="8" maxlength="8" name="Price"></td>
    	</tr>
      </tbody></table>
    </div>
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  3. #3
    Join Date
    Apr 2006
    Posts
    62

    Re: CSS: Cannot Hide Table

    Thanks, I got that to work but another problem arose.

    When I call to it to try to display the elements the table is off center and doesn't line up at all with the other fields. I played around with the display options and the only one I got to work perfectly was "display: table-row". The problem with that is that it works perfectly in FF, but does nothing in IE or Safari. What can fix this?

  4. #4
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    Re: CSS: Cannot Hide Table

    Quote Originally Posted by Tanner8
    Thanks, I got that to work but another problem arose.
    Which of the two methods did you use?

    Quote Originally Posted by Tanner8
    When I call to it to try to display the elements the table is off center and doesn't line up at all with the other fields. I played around with the display options and the only one I got to work perfectly was "display: table-row". The problem with that is that it works perfectly in FF, but does nothing in IE or Safari. What can fix this?
    Again, I'm unable to replicateyour problem. Is there any chance you could post all of the relevent code?
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  5. #5
    Join Date
    Apr 2006
    Posts
    62

    Re: CSS: Cannot Hide Table

    This is what worked the best.

    Code:
    <div>
         <tr id="test" style="display:none;">
                  <td width="60" height="47"><div align="left">Price:</div></td>
                  <td width="110px"><div align="left"><input type="text" size="8" maxlength="8" name="Price"></div></td>
         </tr>
    </div>
    That is in a table. I call the display: table-row using javascript when another element is satisfied. Here is that script.

    Code:
    function Show()
    {
        var showInfo= document.getElementById('test');
        showInfo.style.display='table-row';
    }
    The problem is that it works and displays perfectly fine in FF, but in any other browser it does nothing. I can change it to display:block and it will have an action in all browsers but it will not be lined up and not look the way I want. Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured