Monday, April 3, 2017

forms - What's a clean way to implement two checkboxes that can be "ANDed" or "ORed"?


I have a pretty standard search form on a web site that will return records based on various criteria. Let's assume each record corresponds with a person. A person can have a dog, a car, neither, or both. There are two check boxes:


[A] Only people with dogs.
[B] Only people with cars.


Currently, these are ANDed. That is, if you leave both unchecked, you will get all records. If you check only A, then you'll only get records for people having dogs (they may or may not have cars). If you check only B, you'll only get records for people having cars (they may or may not have dogs). If you check both A+B, you'll only get records for people having cars AND having dogs.


Requirements are now dictating that users may want to search for people having dogs OR cars (or both), because checking both boxes will exclude people who only have one or the other.


Any advice on how to allow the AND and OR to coexist cleanly?


Should I go with radio buttons instead, and offer three choices?:


(A) People with dogs.
(B) People with cars.

(C) People with either dogs or cars.


EDIT: First, thank you all for the answers and comments; you've given me a lot to chew on. I apologize for the abstract example -- if it helps, this is health care system that allows you to pull up lists of patients to "work". The dogs and cars, in this example, correspond to alerts and reminders. An alert is something the patient should have had done but didn't. A reminder is something that the patient will need in the future.


The idea is that you can search for all patients with alerts, pull up each patient, and enter data to "satisfy" the alert (e.g., the patient had a blood test on 03/01/11 with a result of X). In addition, you can search for all patients with reminders, and enter data for those. You can choose both, and in doing so you will get patients that have BOTH alerts and reminders, but then you will be missing out on patients that only have one or the other. I wanted to abstract these in the example so that it was clear that the choices are conceptually different, but are interacted with in a similar fashion (i.e. they are both properties of the person, but they are not two types of the same thing like dogs and cats would be).


Here are my proposed reasons for each option (feel free to dispute any of these):


[*] Checking neither: You want all patients.


[A] Checking only "only people with alerts": You want to address patients with alerts because these are the highest priority. If a patient also has a reminder, that's fine; you may or may not address that reminder.


[B] Checking only "only people with reminders": You want to address patients with reminders because you want to build an appointment list, and/or enter data that would fulfill the reminder (e.g., the patient has a reminder for a blood test next month, but you already performed it yesterday, and here's the data).


[A AND B] Checking both: You want to address patients that have alerts and reminders so you can enter data if necessary, and also schedule appointments because the patients need some test done in the future.


[A OR B] (The New Requirement) Wanting to see patients with either alerts or reminders (or both): You want to see patients that require ANY type of attention or work.


[A XOR B] I don't see any reason for this, but I'm listing it for completion.




Answer



if you have only these three options


go with your last one - three distinct choices in a combo box or radio buttons.



( ) people with dogs ( ) people with cars ( ) people with either dogs or cars



For more options, there are various solutions with different functionality/complexity tradeoff:


'All of the above'



People with

[ ] dogs
[ ] cars
[ ] lasersharks
[ ] all of the above



This basically allows the user to switch between "OR" and "AND" for all options selected. "All of the above" should get some visual distance. It could also be replaced by radio buttons:



People with
( ) any ( ) all of
[ ] dogs

[ ] cars
[ ] lasersharks



This would allow different selectors (such as "only one of"), but appears a bit more complictaed to me


Filter Bar for progressive reduction


If you can display all results (i.e. it's not a bandwidth / server issue), you can provide show all data first, then add filter options, e.g. something like that:


enter image description here


Which would e.g. AND the restrictions from each column, and OR the options per column. For column lice Accessories, the values can be derived from a SELECT DISTINCT query, a column like age ist best handled by allowing to pick a row and to specify ""older than / younger than this".


Query Builders


Free query builders, as mentioned before, will give full flexibility - yet I've seen none that wouldn't scare most casual users. They are a good "advanced" option, asking for some easier UI for common queries, and a method to store and recall previously configured queries.



No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...