One of the great things about building websites for a living is the challenges tend to change from day to day. There’s always a new puzzle to solve.
Take today, for example. I was building a page that contained a series of select (dropdown) boxes. Now, I’ve been around the block once or twice before, and this wasn’t my first time using selects. However, this implementation came with a unique twist: all the boxes contained the exact same options, but we only wanted each to be selectable once. Specifically, each box contained a list of security questions — your mom’s best friend’s grandmother’s maiden name, that sort of thing.
The code looks something like this:
<select class="security" name="security1"> <option value="0">Select a question.</option> <option value="1">Who's your daddy?</option> <option value="2">What's your favorite color?</option> <option value="3">What time is it?</option> </select> <select class="security" name="security2"> <option value="0">Select a question.</option> <option value="1">Who's your daddy?</option> <option value="2">What's your favorite color?</option> <option value="3">What time is it?</option> </select>
Now, naturally, we want the user to select several different security questions. But what’s to stop them from selecting the same question several times? Well, in our case, back-end validation… but I wanted to solve the problem before we got to that point. I wanted to eliminate “selected” questions from all the other dropdown boxes, so it wouldn’t even be an option. This has the added benefit of shortening the list of options as the user goes along, which would make scanning the options easier. Read the rest…








