Title: Conditional Dropdown Fields
Last modified: August 30, 2016

---

# Conditional Dropdown Fields

 *  Resolved [luckydays](https://wordpress.org/support/users/luckydays/)
 * (@luckydays)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/)
 * Hello!
 * I’d like to ask for your assist again 🙂
 * Tell me please how could I manage the following 2 moments:
 * 1) How could I set the dropdown conditional field: so when user choose a number
   of rooms from it, below – appears the necessary amount of fields (rooms)?
 * 2) And how to set those appearing fields to have 2 dropdowns: number of adults
   and number of children?
 * Thanks a lot for your hard and so beneficial work!
 * [https://wordpress.org/plugins/calculated-fields-form/](https://wordpress.org/plugins/calculated-fields-form/)

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6662893)
 * Hi,
 * You should create all fields in the form’s edition, and then, in the main DropDown
   field, press the “Show Dependencies” link (specifically in the choices section),
   and then select the dependent fields to each choice of DropDown field. If you
   want to include multiple fields dependent to a choice, you simply should press
   the “+” button, and select another field.
 * But, how to proceed if you want to create dependencies based in two fields at
   the same time? Using the previous explanation is valid to create chains of dependencies:
   the fields A, B, and C depend to a choice selected in the DropDown field 2, and
   the DropDown field 2, will depend of a choice selected in the DropDown 1. So,
   if you have not selected the correct choice in the DropDown 1 the fields A, B,
   and C won’t be displayed. But, if you want to create dependencies based in the
   value of two fields at the same time, simply, uses a calculated field as auxiliary
   field, and creates the dependecies in function to the equation’s result, of course
   the equation should return a different value in function to the combination of
   values in the other fields.
 * Please, visit the following link for more information:
 * [http://blog.net-factor.com/how-to-use-dependencies-between-fields-in-the-form/](http://blog.net-factor.com/how-to-use-dependencies-between-fields-in-the-form/)
 * Best regards.
 *  Thread Starter [luckydays](https://wordpress.org/support/users/luckydays/)
 * (@luckydays)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6662919)
 * Thank a lot.
 * That was really helpful!
 * Actually I’ve got one more logically arising question:
    how should I set the ‘
   Total Cost’ formula regarding that values for it are in the dropdowns which appear
   in dependencies?
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6662920)
 * Hi,
 * The values of dependent fields are zero, if the fields are not active, so, you
   can use conditional statements in your equations to get the correct result, based
   in if the dependent field is available or not.
 * For example if the fieldname2 field is a dependent field, you can check its value
   in the equation:
 *     ```
       (function(){
       if(fieldname1)
       {
       ....
       }
       })()
       ```
   
 * Replaces the symbols …. by the code to be executed if the value of the fieldname1
   field is available. I’m not sure if the previous explanation responds to your
   question.
 * Best regards.
 *  Thread Starter [luckydays](https://wordpress.org/support/users/luckydays/)
 * (@luckydays)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6663031)
 * Could you clarify please, what exactly do you mean I should place there:
 * > Replaces the symbols …. by the code to be executed if the value of the fieldname1
   > field is available.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6663032)
 * Hi,
 * For example, if you want to return the sum of fields: fieldname2+fieldname3, 
   only if the fieldname1 is defined, and the empty string in other cases the equation
   would be as simple as:
 *     ```
       (function(){
       if(fieldname1)
       {
       return fieldname2+fieldname3;
       }
       return '';
       })()
       ```
   
 * Best regards.
 *  Thread Starter [luckydays](https://wordpress.org/support/users/luckydays/)
 * (@luckydays)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6663034)
 * It seems I’ve understood what you mean here but still can’t see how I could implement
   it for my case.
 * So, I need to have a Total Cost from the number of days person stay in a hotel
   + number of rooms he selected and the dependencies of the adults and children
   number who will be in these rooms (there is a value = price set for the adult
   and for the children separately).
 * For the days of staying in this case the equation is
 * > CDATE( fieldname1+6, ‘mm/dd/yyyy’)
 * So I assume the Total Cost field should start with
 * > abs(fieldname6-fieldname1) * …
 * But how could I add the rooms due to its number and selected amount of adults
   and children?
 * If it sounds confusing – please, let me know, I’ll try to explain more precisely.
 * I really appreciate of your really swift and very helpful assistance!
 * Best wishes!
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6663038)
 * Hi,
 * I really do not understand the structure of your equation, but you are free to
   use the dependent fields in the equation because the value of the dependent fields
   are zero if they are not active. For example, suppose, your equation is:
 * Base price + Number of adults * price of room by adult + Number of children *
   price of room by child
 * Base price: fieldname1
    Number of adults: fieldname2 Price of room by adult: 
   fieldname3 Number of children: fieldname4 Price of room by child: fieldname5
 * Furthermore, the fields: fieldname2, fieldname3, fieldname4, and fieldname5, 
   are dependent fields, but as the values of dependent fields are zero, if they
   are not active, the equation may be written without take in consideration if 
   the dependent fields are active or not:
 * `fieldname1+fieldname2*fieldname3+fieldname4*fieldname5`
 * Best regards.
 *  Thread Starter [luckydays](https://wordpress.org/support/users/luckydays/)
 * (@luckydays)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6663104)
 * Thank you for this clarification!
 * Last question: any chance I could submit a form’s entered data to some kind of
   a table through the OnClick event?
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6663105)
 * Hi,
 * I’m sorry, but I don’t understand your last question. Could you give me additional
   details, please?
 * Best regards.
 *  Thread Starter [luckydays](https://wordpress.org/support/users/luckydays/)
 * (@luckydays)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6663106)
 * Yes, sure.
 * I mean – is there a way to make a form submission with saving data to some table
   inside WP admin dashboard?
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6663107)
 * Hi,
 * The pro version of the plugin stores the submitted information in a table created
   for this. To access to the submitted information, you only need to press the “
   Messages” button associated to the form, in the settings page of the plugin (
   from the list of forms). The “Messages” section includes some options for filtering
   the information, and includes a button for exporting the information to a CSV
   file.
 * Best regards.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Conditional Dropdown Fields’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

## Tags

 * [conditional logic](https://wordpress.org/support/topic-tag/conditional-logic/)
 * [dropdown field](https://wordpress.org/support/topic-tag/dropdown-field/)

 * 11 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/conditional-dropdown-fields/#post-6663107)
 * Status: resolved