• Resolved depping74

    (@depping74)


    I want to create a dropdown list with 6 options. Each option should have two values. One for capacity and another for performance. These are not related in anyway to each other unfortunately. When a selection is made two seperate fields should show the following based on the selected option:
    total capacity
    total performance

    Not sure if I can add two values to each option and how I would use those values in my calculated fields?

    Awesome plugin by the way!

    http://wordpress.org/plugins/calculated-fields-form/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    To create your form will be required the use of dependencies. Creates two hidden fields for each drop-down menu option, and set the fields dependent of the corresponding drop-down option.

    Suppose that fieldname1 and fieldname2 are the hidden fields associated to the first option of drop-down field, for total capacity and total performance, respectively.

    fieldname3 and fieldname4 to the second option.
    fieldname5 and fieldname6 to the third option.
    etc.

    The values of each drop-down options will be: 1, 2 , 3, …, 6, and the name of field in my example will be fieldname10.

    Now, suppose that equation for total capacity is the value corresponding to the hidden field associated to the option selected multiplied by 5, and the equation for total performance is the value corresponding to the hidden field associated to the option selected plus 5

    I will use only three options in my example, you should extend the equations to your options.

    Equation for total capacity:

    (function(){
    var v;
    if(fieldname10==1) v=fieldname1;
    if(fieldname10==2) v=fieldname3;
    if(fieldname10==3) v=fieldname5;

    return v*5;
    })()

    Equation for total performance:

    (function(){
    var v;
    if(fieldname10==1) v=fieldname2;
    if(fieldname10==2) v=fieldname4;
    if(fieldname10==3) v=fieldname6;

    return v+5;
    })()

    Use the principles in the previous demo in your own form.

    Thread Starter depping74

    (@depping74)

    That works great, thanks! Your quick response / help is much appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Use two values in a Dropdown list’ is closed to new replies.