• Resolved Damn!

    (@greedymind)


    Hello

    I would like to know if it is possible to group 3 fields? for example, lets take 3 number fields A, B and C . I want their sum to not exceed 100, as in if a user enters 50 in A then he shouldn’t be able to enter a value more than 50 in B and C. And if the user enter 40 in B then he shouldn’t be able to enter a value more than 10 since he enter 50 in A and 40 in B (total A+B+C = 100). If he tried to enter a value more than 10 in C, he should get an error saying that “This field cannot accept a value more than 10 since the field A and B sums up to 90” or something like that.

    Thanks in advance.

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

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

    (@codepeople)

    Hi,

    For example, assuming that the fields: A, B, and C, are: fieldname1, fieldname2, and fieldname3, you simply should insert a calculated field in the form, and as the calculated field is not relevant for the form’s interface, tick the checkbox: “Hide Field From Public Page”. Finally, assign the equation below to the calculated field:

    (function(){
    if(fieldname1+fieldname2+fieldname3 > 100 ) alert( 'The sum of fields: A, B, and C cannot be greater than 100' );
    })()

    Best regards.

    Thread Starter Damn!

    (@greedymind)

    thank you, Is there anyway I can do this with the help of 3 Sliders?

    Plugin Author codepeople

    (@codepeople)

    Hi,

    The process is the same, but instead to use “Number” fields, insert sliders, unfortunately the maximum values of fields are not modified at runtime (you can use 100 in each of them), but at least you can indicate the user that values selected are incorrect.

    Best regards.

    Thread Starter Damn!

    (@greedymind)

    hello,

    can you tell me how to set the values of sliders according to the results from a calculated field. Lets say i have calculated field with a result of 50, i want the slider to also point 50.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    Yes, that’s possible, I’ve answered a similar question in the following support thread:

    https://wordpress.org/support/topic/how-to-feed-the-value-to-a-slider?replies=3

    Best regards.

    Thread Starter Damn!

    (@greedymind)

    Hello,

    Thank you, It worked. One more thing, Is it possible to add a % symbol after the slider’s numeric field? because i’m trying to make the slider show percentages.

    Thanks in advance.

    Thread Starter Damn!

    (@greedymind)

    (function(){
    if(fieldname1+fieldname2+fieldname3 > 100 ) alert( 'The sum of fields: A, B, and C cannot be greater than 100' );
    })()

    The above code triggers the alert twice, is it possible to make it alert once?

    Also how to force a Div container to align right?

    Sorry for asking too many questions.

    Thanks in advance.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    To align the caption at right, you simply should insert a “HTML Content” field with the piece of code below as its content:

    <style>
    .slider-container div { text-align:right; }
    </style>

    About the alert message that is displayed twice, what version of the plugin are you using?

    Best regards.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    If you need more specific support, I can offer you a custom coding service, in whose case, you should contact me through my personal website:

    http://cff.dwbooster.com/customization

    Best regards.

    Thread Starter Damn!

    (@greedymind)

    I’m using version 1.0.113

    Plugin Author codepeople

    (@codepeople)

    Hi,

    In this case I recommend you a different solution:

    1. Insert after the “Sliders” fields, a “HTML Container” field, and enter, as its content, the piece of code below:

    <div class="my-error-mssg"></div>
    <style>
    .my-error-mssg{font-weight: bold; color: #ff0000;}
    </style>

    2. Modify the equation as follows:

    (function(){
    jQuery( '.my-error-mssg' ).html( IF(fieldname1+fieldname2+fieldname3 > 100, 'The sum of fields: A, B, and C cannot be greater than 100', '') );
    })()

    I’m sorry, but if you need additional help implementing your equations, you should hire a custom coding service through my personal website:

    http://cff.dwbooster.com/customization

    Best regards.

    Thread Starter Damn!

    (@greedymind)

    thanks a lot.

    • This reply was modified 7 years, 7 months ago by Damn!.
Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Is it possible to group 3 fields?’ is closed to new replies.