wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Issue with style display property Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Issue with style display property" Watch "Issue with style display property" New topic
Author

Issue with style display property

Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 818
I have 3 tr tags (rows) in my table. Each tr tag is labelled 1 thru 3 (so their id property is set to Row1, Row2, and Row3). When the page loads, the first tr tag is displayed (default) and the second and third tr tags have an in-line stylesheet attached (i.e. style="display: none;"). I have a javascript function that accepts a number from 1 to 3 and, depending on the number selected that line is displayed and the others hidden. Here's the small bit of code used in this :


Here is the source code of the page showing the 3 rows in the table :



Any help would be appreciated. Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61084
    
  66

What's the problem?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 818
Lol. Got caught up with posting the info. Can't you read minds? When I click a button that is to display the second or third row the content from the row gets pushed together. So instead of the content being displayed in the cells spaced apart it's as though the <td> tags are completely ignored. Each td tag should be 25% of the table and displayed fine when initially displayed.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61084
    
  66

You probably don't want "inline". Try letting the element take on its natural state by specifying "".

If that fails, it should probably be "block".

(Hint, hint: personally I'd be using jQuery's show() and hide() functions that always figure out how to do it right.)
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 818
Thanks Bear. Worked great! Just fooling around with some code, when doing that I'd rather take the path not traveled when learning.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I really do not htink you want block either since certain browsers would want "table-row".

The easiest way to show the item with display is to set it to ""

myObj.display = "";


When you do that, the default for the element is selected.

Eric
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 818
Thanks guys! Setting it to "" worked great.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue with style display property