• Resolved JoeLandolfi

    (@joelandolfi)


    Hi guys:

    This little bit code is what’s keeping me from completing a large project where users can have their songs mastered at a varying range of prices. 1-3 for $75 each; 4-6 for $65 each; 7-12 for $55 each. I’ve been able to successfully create an equation and it is working perfectly:

    (function(){
    if(fieldname10 <= 3) return fieldname10*75;
    if(fieldname10 >= 4 && fieldname10 <= 6) return fieldname10*65;
    if(fieldname10 >= 7 && fieldname10 <= 12) return fieldname10*55;
    })();

    The hiccup is that there are also “extras” a user can choose with your order represented as radio buttons. I’ve seen the jquery examples at how to recognize a selected radio button but I have no idea how to make this work – mainly, grab the price associated with the radio buttons ($25) and pass it as equation: radio button + total = Grand Total. Can someone please lend some assistance.? Thank you so much.

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

    (@codepeople)

    Hello,

    The easiest way would be enter the prices as the values of the radio button’s choices. For example, if the radio buttons field is the fieldname11, the equation could be:

    (function(){
    var n = 0;
    if(fieldname10 <= 3) n = 75;
    else if(fieldname10 <= 6) n = 65;
    else if(fieldname10 <= 12) n = 55;
    
    return fieldname10*n+fieldname11;
    })();

    Best regards.

    Thread Starter JoeLandolfi

    (@joelandolfi)

    Thank you for this. The question is more of how do I (a) identify and extract the value from a specific radio button and (b) add that value to a “Total” field that calculated a value from anther place in the form. From what you list above, just referencing the field isn’t going to help since it is specific choices of that field that I need.

    For example, the radio buttons are:

    x = FREE
    y = $25
    x = $25

    Thanks.

    joe

    Plugin Author codepeople

    (@codepeople)

    Hello,

    The texts and values of radio buttons are independents, you can define the choices as:

    First choice:
    Text: Free
    Value: 0

    Second choice:
    Text: $25
    Value: 25

    If the radio buttons field is the fieldname1, and the other calculated field is the fieldname2, the equation associated to the calculated field for the total would be simply:

    fieldname1+fieldname2

    Best regards.

    Thread Starter JoeLandolfi

    (@joelandolfi)

    I figured it out! Your code worked but I couldn’t understand it. But now I do. As always many thanks from the forum!

    Plugin Author codepeople

    (@codepeople)

    Hello,

    It has been a pleasure.

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Calculating number values with radio button values’ is closed to new replies.