View Single Post
Old 08-29-2012, 12:53 AM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,249
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
A better way might be to simply hide everything to begin with and then make an array of things to show for each category, putting them all into a master object.

After all, you don't really need to ever hide anything, do you? Once you have checked a category for the response, you want to show (additional) items, not hide ones already selected.

And then just start over with each response, starting with everything hidden?

Example:
Code:
var categories = {
    "Email - Standard" : ["customernamespan", "servicerequestnumberspan", 
                                     "servicerequestnumberspan", "standardspan", "signaturespan" ],
    "Email - Unsupported" : ["customernamespan", "servicerequestnumberspan", 
                                           "standardspan", "signaturespan"].
     ...
};

... get the value from checkbox/select ...
var choice = ... one of the above categoried ...

var category = categories[choice];
for ( var s = 0; s < category.length; ++s )
{
     document.getElementById(category[s]).style.display = "block"; /* or "inline" */
}
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
tony0706 (08-29-2012)