• Resolved gabekahsen

    (@gabekahsen)


    I’m creating a complex series of questions to solve a simple equation. I’ve gotten it to work 99% of the time, but for certain inputs the calculated box remains blank.

    fieldname5 -checkboxes
    Choice Text: Yes – Value = 24.5, No – Value = 0.0
    Value to submit: choice value

    fieldname4 – dropdown
    Choices Text: Indoor Cage – Value = 81, Indoor Aviary = 103, Outdoor Aviary Summer = 130.3, Outdoor Aviary Winter = 152.5, Free-living = 155.6
    Value to submit: Choice Value

    fieldname6 – number
    Number Format: number

    fieldname1 – calculated field

    (function(){

    if(fieldname6 > 0) return prec((fieldname5+fieldname4)*(POW(fieldname6*0.001), 0.73),2)

    })();

    Whenever I select No, an aviary or greater option, and put a greater weight (i.e. 1000) the fieldname1 comes back blank. Looking for assistance please! Thank you!

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @gabekahsen

    There is an issues in your equation:

    (function(){
    
    if(fieldname6 > 0) return prec((fieldname5+fieldname4)*(POW(fieldname6*0.001), 0.73),2)
    
    })();

    The POW operation requires two parameters, but you are including the close parentheses in the wrong place. The correct would be:

    (function(){
    
    if(fieldname6 > 0) return PREC((fieldname5+fieldname4)*POW(fieldname6*0.001, 0.73),2)
    
    })();

    Best regards.

    Thread Starter gabekahsen

    (@gabekahsen)

    Hello. Thanks for the quick response. I altered the code to the correct format, but the issue persists. Whenever I select yes for the first question and any value above indoor aviary for the second, the calculated field remains blank no matter what I put for the third weight value.

    Plugin Author codepeople

    (@codepeople)

    Hello @gabekahsen

    If you are using the fieldname5 field in a sum, you should tick the checkbox: “Merge ticked up options (sum or concatenation) or their values are returned as an array” in its settings. If the attribute is unticked, the fields’ value would be an array and not a number.

    Best regards.

    • This reply was modified 3 years, 7 months ago by codepeople.
    Thread Starter gabekahsen

    (@gabekahsen)

    That worked, thank you so much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Creating a Diet Calculator, Getting Error with Certain Inputs’ is closed to new replies.