Hello, does anyone knows how can I achieve the following functionality using Webform 3?

1) User selects option from a drop down select box
2) Another select box is populated using the value from first select

Example: User selects a country from list of countries, then the second box populates with the cities for that particular selected country.

Do I need to create a multistep form to achieve the desired functionality?

Thanks

Comments

Eldeem’s picture

You can try using webform conditional module.
http://drupal.org/project/webform_conditional

However, I'm not sure that it is the best way to do it.

quicksketch’s picture

Yeah you'd have to either use a multi-page form or webform_conditional and build a different select list for each possible option in the first select list. Also see the official feature request for exactly what you're requesting: #329504: Hierarchical Select Lists.

luthien’s picture

Do you know what complicates things for me if I use http://drupal.org/project/webform_conditional? the fact that I'm using the dynamic_select module to populate my select box. The second select will be another dynamic_select box. It is an extreme example of a hierarchical select list but dynamically generated. I basically need to pass the value from first select box to the query in second box and the array will be automatically generated without the need of creating a different list for each option.

luthien’s picture

quicksketch, how do I pass a value selected in step 1 of a multistep form to the second step's url?

quicksketch’s picture

All of the previous steps data will be available in $form_state['storage'], but I don't know how that would factor into your custom PHP code or if $form_state is even available in a dynamic_select. You're best off asking the developer of that component, since I don't really endorse use of it.

luthien’s picture

Temporary solution using multistep form:

1) created the first "dynamic select"
2) added a page break
3) populated the second "dynamic select" passing this value from 1):

$_POST['submitted']["my_field_name"]

Note: $form_state['storage'] was empty. Please remember that I'm using the dynamic select module to populate the drop down box after querying an external database.

quicksketch’s picture

Status: Active » Closed (fixed)