WordPress.org

Ready to get started?Download WordPress

Forums

Calculated Fields Form
[resolved] calculated field with multiple denpendencies (3 posts)

  1. ruicampos
    Member
    Posted 9 months ago #

    the FINAL result of my form should be a estimated price for some materials that have price by square meter.

    Have radio button with 4 option(paper,plastic,fabric and wood), which one with denpencies to another radio buttons (paper1, paper2, paper3 and paper4 fieldname10 , and se same for pastic fieldname6, fabric fieldname8 and wood fieldname11). see form

    the value that result from the choice of one of these materials is the price per meter square see image

    then, two number: length fieldname9 and height fieldname2, so i can multiply them to get number of square meters, and multiply that value with the price per meter square(that was selected above)

    To calculate this (price for the select material with the required measures) e try 2 different formulas but none works properly:

    first
    (fieldname9*fieldname2)*(fieldname10)

    only works if the material select is paper

    second:
    (fieldname9*fieldname2)*(fieldname10+fieldname6+fieldname8+fieldname11)

    only works if the "user" selects just a material from one type, if then he changes the type of material and select another material, it will add the current result to the previous.

    can anyone help with the formula that i shoud have to get this working?

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

  2. codepeople
    Member
    Plugin Author

    Posted 9 months ago #

    Hi,

    Your form contains multiple options, so the you can't get the price through a simple mathematical expression, and it requires a more complex equation to calculate the price. Please, use the equation below:

    (function(){
    var sq = fieldname9*fieldname2;
    switch( fieldname5 ){
    case 'paper': return sq*fieldname10;
    case 'plastic': return sq*fieldname6;
    case 'fabric': return sq*fieldname8;
    case 'wood': return sq*fieldname11;
    }
    })();

  3. ruicampos
    Member
    Posted 9 months ago #

    works!

    Thank you so much

Reply

You must log in to post.

About this Plugin

About this Topic