Select values in several dropdowns and show results.

cneumann's picture

Hi All,
I am wondering if anyone can point me in the right direction here.
I would like to create a node/page/block/whatever that does the following:

For the sake of simplicity, there are 3 drop down menus. Each menu would have a list of data that is pre-defined. You would see the alpha numeric value only in the drop down, but the items in parenthesis are the values the user would see after they select the initial value and select Go.

Drop1 Drop2 Drop3....etc
-1 (red) -a (box) -x (bag)
-2 (blue) -b (circle) -y (basket)
-3 (green) -c (triangle) -z (cart)

and a button marked Go

If you choose 1, b, y and select Go you would see: "You have a Blue Circle in a Basket"
If you choose 3, a, x and select Go you would see" You have a Green Box in a Bag. and so on.

I have tried exposing Views and other modules and I cannot get it to work properly. It is usually something small and simple and I would greatly appreciate the help. If I have one good example, I can take it from there. I have a dev server if you need it.

Thanks!

Comments

I would assume Views Exposed Filters should work...

DYdave's picture

Hi cneumann,

From what I understood, you would like to Expose Filters in a Views to allow users to filter displayed results with 3 distinct dropdowns. But it would seem you would already have tried that:

I have tried exposing Views and other modules and I cannot get it to work properly.

So could you perhaps provide a little bit more information on what you couldn't get to work exactly?
I would recommend you perhaps take another try in the Views Exposed Filters direction and see if you could potentially come up with more specific issues/problems encountered.

Thanks in advance to everyone for your comments and feedbacks.
Cheers!

Thank you for your response.

cneumann's picture

Hi DYdave,
After giving this project some thought, I think that I need to use conditional/dynamic drop downs. I tried out the hierarchical_select but could not get it to work at all. I will try Views Exposed Filters again and see if I can get it to work, bet me explain the concept further, I may be going in the wrong direction...

The final product will have 10-14 drop downs, the first 4-5 will be conditional and the rest will pull from a dataset depending on the first selections and the data will be repeated in the remainder. I can create a design workflow and attach it here if that would help.

I have a sandbox that I can share if that would be helpful. If I have some direction with a solid example of how to make this work I can take it from there.

Views Dependent Filters or Custom JavaScript maybe?

DYdave's picture

Hi cneumann,

According to what you would seem to try to achieve, I found a module that might be helpful: Views Dependent Filters (not sure if you already tried this one).

Allows the presence of exposed filters on a view to be controlled by values in another exposed filter.

Unfortunately, I have never personally tested this module, so it will be hard for me to tell you whether this would lead to a dead end or not.

However, I can recall having already seen something like this achieved in the past with custom code, based on an implementation of hook_form_alter (or one of its related form specific hooks) to modify the Views Exposed Filters form.

You would then be able to modify as you would like either the generated HTML (fields and markup on page load), or add your custom JavaScript logic to instantiate (or hide/display) "fake" fields which would only be there for the display (for example, to break down a single filter into two, to give user the illusion it is two different dropdowns, when in fact a single value is submitted).

Refreshing asynchronously (AJAX) the values in the dropdowns would also be possible by attaching JS behaviors to the dropdown (no matter how they were instantiated on the page), and implementing menu callbacks to return potential arrays of values.

To sum this up, an implementation with custom code could include:
- Server logic: Modification of the Views Exposed Filters form to add, hide, remove, split any fields and load custom JS. Optional: add a form submit callback if submitted values would need to be reassembled or processed in any ways (merging multiple values for a single filter).
- Front-end logic: Custom JS, which could instantiate any fields (from a JSON object for example), remove, hide/display, split, conditionally relate the dropdowns, etc...
Optional: Add a few more JS behaviors with menu callbacks if you wish to Ajaxify dropdowns. For more information on this see AJAX Forms in Drupal 7.
 

This may sound complicated or a lot of work, but given the flexibility that you would seem to require: 10-14 drop downs which could be conditionally related with various rules corresponding to different data values, ultimately, I am afraid you might have to write some custom code, at some point, if you would like to match closer with your requirements.

Feel free to let us know if you would have any particular questions, comments, issues, suggestions, ideas, or concerns on any aspects of this reply, I would certainly be glad to provide more information.

I hope this will help you to move forward and would surely be interested to hear which solution you decided to follow (in particular whether you found a module that could work in this case).

Thanks in advance to everyone for your testing, comments, ideas and suggestions.
Cheers!

Still no go...

cneumann's picture

Hi again, my day job has me busy. I have tried it and still cannot get it to work. I think that if I can have one example I can expand on it easily I just need to see it in front of me. I don't have the time or expertise to write code myself.

Another approach is to enter numeric values in fields and query based on what the user enters and produce the same output:

if you ENTER 1 in field one, b in field two, y in field 3 and select Go you would see:
"You have a Blue Circle in a Basket"

Is that easier? Is there another method like JS that can do this?

Signed,
Desperate.

SF Bay Area

Group categories

Resources

user group

Group events

Add to calendar

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week