Connecting Tech Pros Worldwide Forums | Help | Site Map

JavaScript - Show/Hide table rows with unchecked checkboxes

Newbie
 
Join Date: May 2006
Posts: 1
#1: May 3 '06
Hi -
I have a table with about 30 rows, which contain a checkbox and a bit of text each. What I'm trying to find a way to do is to have 2 buttons at the bottom of the page - HIDE & SHOW. When the HIDE button is clicked, I need to hide all the table rows which contain UNCHECKED textboxes. When the SHOW button is clicked, I want to restore the visibility of all the rows. I need to do this in JavaScript (which is what I'm having trouble with) - I've been able to get bits of it to work at various times, but I'm running out of time and I really need help. Any suggestions anyone has would be more than appreciated!
Thanks!
j-

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Apr 24 '08

re: JavaScript - Show/Hide table rows with unchecked checkboxes


To find rows with unchecked checkboxes, check the "checked" property. If it's false, the checkbox is unchecked. To determine the row, you could use parentNode to refer to the cell and then the row and set it's style.display property to "none" to hide it.

To show a row, IE says "block", but the proper setting should be "table-row". Setting it to "" usually works.
Reply


Similar JavaScript / Ajax / DHTML bytes