Dynamically create Select criteria
- To: mathgroup at smc.vnet.net
- Subject: [mg125364] Dynamically create Select criteria
- From: Jack McInerney <ejmcinerney at gmail.com>
- Date: Fri, 9 Mar 2012 06:10:41 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
I have a database in the form of a big list, and want to select a subset of this list, by allowing the user to click on checkboxes. The example below shows the idea. Given a list of animals, lets say I want to select all the cats that are 1 year old, or all of the dogs and cats. I can't figure out how to use the output of my checkboxes to dynamically create a selection criteria for the Select function. Is this possible? Any thoughts would be appreciated. data={{"fido", "dog",8}, {"Sparky", "dog",2}, {"Shadow", "cat",1}, {"Cuddles", "cat",3}, {"Cutey", "rabbit",1}}; CheckboxBar[Dynamic[type], DeleteDuplicates[data[[All,2]] ]] CheckboxBar[Dynamic[age], Sort[DeleteDuplicates[data[[All,3]] ]]] Dynamic[Select[data, #[[2]]==type[[1]] && #[[3]]==age[[1]]&]] (*<-- criteria should depend on which boxes have been checked by user *) Thanks, Jack
- Follow-Ups:
- Re: Dynamically create Select criteria
- From: Bob Hanlon <hanlonr357@gmail.com>
- Re: Dynamically create Select criteria