View Full Version : [DHTML] Check/Uncheck columns script
09-10-2006, 07:37 AM
1) CODE TITLE: Check/Uncheck columns script
2) AUTHOR NAME/NOTES: jscheuer1
4) URL TO CODE: http://home.comcast.net/~jscheuer1/side/table_check.htm
or, ATTACHED BELOW (see #3 in guidelines below):
09-10-2006, 08:41 PM
But it errors out in older browsers due to the lack of feature detection. You've gone over-the-top with regular expression usage where simple string comparison (and no toLowerCase/toUpperCase) would do, and you'll invoke IE's memory leak due to the DOM-involved closures you create.
Another issue is the handling of the "check all" checkbox, both in that it always exists (the control and label should be generated), and that you hide the cell contents. The latter case isn't helped because the original request didn't really state what exactly was needed so you had to guess, but it doesn't seem reasonable for the cell contents to be mutually exclusive. The original contents must somehow be useful otherwise they shouldn't exist in the first place.
Most of the time, there will only be a single set of checkboxes that the user will want to control as a group. As a result, the controls for that group can be placed anywhere (within reason), rather than being limited to somewhere in the table (or whatever container is in use). It could simply be a checkbox next to the column heading, or in combination with an explicit label.
I don't mind suggesting an alternative, but a more specific (and realistic) specification is needed.
09-14-2006, 06:59 AM
I really wasn't all that concerned with legacy browsers when I wrote the code (focusing on minimal markup hooks like id's and classes, mainly) but, I usually am. So, point well taken. I think I am just beginning to really get the hang of regular expressions, having struggled along with them off and on for quite some time. I did get carried away. The idea of the alternate text was just so that an empty or display none tr wouldn't have to be used as, they look odd. This alternate text could be used even as part of the initialized content though, that whole bit is at the designer's discretion (configurable in the script and/or by leaving 'displayed under all circumstances text' with the td as the immediate parent element). I'm not attached to this being exclusively my code or even my code at all. Feel free to write an update or a completely different version using your ideas. If I feel motivated to do so I may update this one myself as well, or we could as I say, work it as a joint credit.
09-17-2006, 08:25 PM
The idea of the alternate text was just so that an empty or display none tr wouldn't have to be used as, they look odd.
I can appreciate that, but the columns of a table should normally have headings anyway, so the checkboxes could be generated dynamically and inserted there. Similarly, an extra row could be created using the DOM at run-time. It would look stranger, I should think, if the alternate text was just some filler (as it was in your example).
I'm not attached to this being exclusively my code or even my code at all. Feel free to write an update or a completely different version using your ideas.
As I wrote previously, I'd prefer a better idea of what the intention really is, first.
Consider that a set of checkboxes that will have a common control should have something in common. In markup, that relationship is usually established by giving them the same control name. If that were the case, there's no need to traverse the table at all, but simply obtain a collection of those elements from the form. Life becomes a whole lot easier.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.