• Resolved monika064

    (@monika064)


    Hi, I’m trying to create a calculator that offers 2 options: inches and centimeters. And it would have to calculate differently based on what the person picked. I managed to create a checkbox but it doesn’t work in a way that would be logical. If I have “inches” checked by default, and I want to switch to “centimeters”, it won’t allow me to do that. I first have to remove the tick from “inches” and then I can choose “centimeters”. And that is not very intuitive and it gives an impression the calculator is not working. Is there a way to make it work that way?

    Thank you

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

    (@codepeople)

    Hello @monika064

    Thank you very much for using our plugin. The issue is simple you are using the incorrect control. You are describing the behavior of a radio button field. You tried to emulate the behavior of radio buttons by using a checkbox field limiting the number of choices to tick at once. Please, use a radio buttons field for the measurement units.

    Best regards.

    Thread Starter monika064

    (@monika064)

    Wonderful! Thank you so much for clearing that out for me ??

    Thread Starter monika064

    (@monika064)

    Hi, can I please ask one more question. I can’t seem to figure it out. I have a Calculated Field and I would like it be completely blank while it’s not showing any results yet. Currently, there is always “0” inside. I have “dependencies” that work if the result is less than 7 -> show “fieldX” and since the placeholder is always “0”, it’s showing the text by default.

    I thought it might work if I leave predefined value blank and I check “Use predefined value as placeholder.” but it doesn’t work. Even if I try to put something like “-” in the predefined value, it doesn’t show up as a placeholder in the field, it just keeps showing “0”.

    Thank you!

    • This reply was modified 2 years, 7 months ago by monika064.
    Plugin Author codepeople

    (@codepeople)

    Hello @monika064

    If the form is configured to evaluate the equations dynamically (it is a checkbox in the “Form Settings” tab), the equation in the calculated field is evaluated after rendering the form:

    https://resources.developers4web.com/cff/images/documentation/form-settings-tab.png

    So, you have two alternatives:

    You can disable the dynamic evaluation of the equations. But in this case, you should insert a button in the form and tick the “Calculate” option as its type to evaluate the equations manually.

    Or, you can use conditional statements in the equations. For example, if you have the equation fieldname1+fieldname2, and you want to evaluate it only after the user enter the values of both fields, you can edit the equation as follows:

    IF(AND(fieldname1|r != '', fieldname2|r != ''), fieldname1+fieldname2, '')

    The plugin always tries to transform the fields values into numbers to use them in the mathematical operations. But using the field’s name with the |r modifier, you can access to its raw value without preprocessing.

    The previous equation can be read as follows:

    If the values of fields fieldname1 and fieldname2 are not empty texts, then evaluate the mathematical operation (fieldname1+fieldname2), else return empty text ('').

    Best regards.

    Thread Starter monika064

    (@monika064)

    Thank you for a detailed explanation!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Switching between 2 checkboxes’ is closed to new replies.