Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to change the visibility of specific elements using the display attribute (html/php)

How to change the visibility of specific elements using the display attribute (html/php)

Problem

Disclaimer: This is a code segment, not the source in its entirety.

So currently I have a large table enveloping individual tables for a given day (Monday/Tuesday). For each day there's a dropdown box that is supposed to generate large and small text boxes, and that part works (as evidenced in the Tuesday portion).

The part I'm having problems with is trying to change the visibility of anything else, whether it's an h2 Element, a td element or even just the tbody element (I believe the default display values for each of those are "block", "table-row" and "table-row-group" respectively).

The error I've been getting in Chrome's source console is that no matter what type the element is (except for text boxes), it says that its undefined, even though the text boxes have their names and ids displayed in the exact same way.

Please let me know if you understand why this is happening. ProblemSegment Note: the particular element that I'm working with at the moment is "mondayWork" in the monday section.

                
First and Last Name
Email Address
Date
Monday (Date)
Tuesday (Date)

Tasks


"; } } ?>
Copyright ©

Problem courtesy of: Michael Anthony Leber

Solution

this is because this.form['mondayWork'] not refer to element belonging to the form. mondayWork is belong in tbody tag and it's id attribute. To select this id you have to use document.getElementById

 document.getElementById('mondayWork').style.display = 'none'
Solution courtesy of: siropo

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

How to change the visibility of specific elements using the display attribute (html/php)

Email
Facebook
Pinterest
Twitter
×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×