Javascript tip: Style display and table rows

It seems like about half the world knows this one, but the other half doesn’t.

Let’s say you have a table, and you want to be able to toggle various rows on and off. So you write yourself a couple of simple Javascript functions to hide and show your stuff.

function hide(thingID){
document.getElementById(thingID).style.display = 'none';
}

function show(thingID){
document.getElementById(thingID).style.display = 'block';
}

Here’s the problem: display:block turns a table row into a block element — which is to say it compresses the whole table row into one big chunk and stuffs it into the space for your first table cell in that row.

If you do your research, you’ll quickly learn that the W3C says you’re supposed to use “display:table-row” for tables. But when you change your “show” function to use the preferred method, all the standards-compliant browsers start working, but IE 7 and the other annoying old IE browsers you’re forced to support just flat out drop the rows.

The secret? So obvious almost no one thinks of it until they’re told:

function show(thingID){
document.getElementById(thingID).style.display = '';
}

By setting the display to effectively “ain’t got one”, you tell the browser to display the row the way it would have if you hadn’t messed with it. Which results in what you were looking for:

To check the results in your browser(s) of choice, feel free to fiddle with this test page.

Pet peeves: Review pages you can’t review

There’s security, and then there’s stupidity.

We’re all familiar by now with the security pattern where you set up 2-3 questions that “only you” will know the answer to (well, only you and people who know you really well, anyway) in addition to your username and password. It essentially sets up a two-password system. If you can’t answer the first password (your security question’s answer) you never get to the second password, thus securing it.

Or something.

I have a lot of problems with that security pattern, which I won’t get into here, because this post isn’t about the security, it’s about the stupidity. It’s security when you ask me to set up a double-password system. Since it’s critical information, it’s good design and good sense to ask me to review the information before I submit it, and print it for my records. One password is hard enough to remember, but this pattern essentially asks me to set up three.

It’s stupidity when you decide that your security policies need to be strong that when you ask me to review my information for accuracy, you obscure the answers to my questions.

And yet… that’s what we have here.
Asterisking out the answers to the security questions? Not helpful when part of reviewing is confirming that I spelled them right!
I’m willing to guess that the vast majority of people are not dumb enough to fill out a registration form for a medical billing website on the Jumbotron of their local stadium, or anywhere else that would allow a significant number of people to view the process. So why make that registration even harder by blocking the review of critical account-access-granting information? It’s security absurdity.

Hello world!

It’s obligatory to use that as the name of your first post, same as it is to use it for the first application you write in a new language.

At least, that’s what these fellas behind me with the suits, dark glasses, and baseball bats contend. 

Let’s go with that.