I'm building an application for my office that allows users to search a database of resources. I've been asked to design a "Wizard" style interface to avoid a long, cumbersome form. It basically works like this:
You pick your role (i.e. what do I do for a living). This is a set of radio buttons.
You choose the catagory(ies) that you're interested in. This is a set of checkboxes.
You pick the subcatagory(ies) you're interested in. This is a set of checkboxes.
You choose your level of proficiency. This is a set of radio buttons.
It works well, BUT, there are situations where you can arrive at the dreaded "no records returned" result. What I'd like to do is for each step, eliminate the choices in the next step that don't have any records. Aside from querying each of the possibilities (and in step 3 there are around 30), I can't think of a good way to do this.
This problem is even more complex than you're making it out to be since it could be possible that I select something in step 1 for which I will never get any result, but there is data in step 2, 3 and 4. However, whatever I select over there, I'll always get "no results".
So what you want to do is for each option in each step, look ahead all other steps until the end to see if the options could lead somewhere, which is indeed a hell of a job.
This is one of the cases I would actually consider adding redundant data to the database; on each item store whether it should be visible or not.
To get these values, start at level 4: if there are no children, set visible to 0, otherwise set visible to 1
Then goto step 3: if there are no children or all children have visible=0, set visible to 0, otherwise set visible to 1
Then do the same in step 1 and step 2 as you did in step 3.
When you show the options, only show the options that have visible = 1
Lastly, every time the data changes, recalculate the visible fields (which you can do more intelligently than just walking over all items every time!)
Like I said above, the visible field holds redundant data, but it's a heck of a lot faster to calculate it every once in a while then to calculate it on each and every step.
So IMO the redundancy is worth it.
Does the user have to start at step 1?
And do you want to show step 2 with the possible values only after the user has made his choice at step 1?
Then you might want to take a look at AJAX (and simple form submission after each step for users that have JS disabled.
LOL! Well I was thinking it was pretty complicated as it was. Now I'm really worried!
Well here's the thing. We're a gov't agency so we cannot rely on JS (or anything client-side) to do anything. I have a page with a form, and the user selects his answer to step 1. Once he submits, he gets the next form for step 2. When he submits that answer, he get step 3 and so on. So the form is submitted for each step, so it's possible to do a query based on his choice, and I think I only need to look ahead the one step.
Hope that made sense.
No, see my post above. If you only look one step ahead you can still get to a dead end, unless you've ensured that every entry on level n needs to have at least one corresponding entry on level n+1
Take a look at the image I've attached with this post.
For simplicity sake, I've only put one role in there. Let's say I pick that role.
Then I can take a pick of 3 categories. Let's say I pick all three.
Subcategory 3 is already drained, subcategory 2 gives me 2 options and subcategory 1 gives me only option. Which directly poses another question: do you want to present the user with a choice of only option, or do you just skip it altogether? I know there is a traffic website here in the Netherlands where you can enter two cities and it will show you how to travel between them. Sometimes it doesn't get one of the cities you enter and comes up "With did you mean ..." and then gives a "list" of radio buttons with just one option you have to select to continue. It annoys the crap out of me.
I digress. Let's say I've picked subcategory 4, I am presented with "Proficiency 1" and "Proficiency 2". And here's the kicker: no matter which one I select I get "no results".
Now, when I was at selecting the role I could not see it because there were roles in the next step, and when I was at select subcategories I couldn't see it because there were proficiencies in the next step, but it really didn't matter what I did once I picked the role, I would have never get any results, simply because there aren't any. And you can't know that by just looking one step ahead.
Hence my suggestion in post #2
Does that make sense?
Oh dear. Funny how a picture can say a thousand words. I see now how monumental of a task this is, and am starting to think that maybe it's not worth tackling, especially considering my rather modest skill level.
I'm going to re-read your first post once my brain has adjusted to daylight savings time, and see if I can get my head around what you suggested.