• Resolved rocketpig3

    (@rocketpig3)


    I have a form that returns a number given a set of other numeric/boolean inputs. The form evaluates on click of a button.

    I would like to take this output and use it for a second stage of the form, given further input. I would like this second stage to be evaluated on the click of a second button (given it requires further inputs – not all people will need to submit it).

    Two ways I thought of doing this:

    1. Adding more fields and buttons within the same form. Difficulty: having it evaluate separately. What is the onclick event to evaluate only a specific calculated field, or fields?

    2. Adding a separate form below the first one. Difficulty: referencing the output of the field in the other form.

    Which would be easiest, and how would I go about doing this?

    Thanks!

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

    (@codepeople)

    Hello @rocketpig3

    The calculate button evaluates the equations associated with all the calculated fields in the form. So, the workaround would be to include conditional operations or conditional statements of javascript as part of the equations.

    For example, assuming the first calculated field is fieldname1, and the additional fields are: the fieldname2 and fieldname3, and you want to make the sum only after entering the three fields.

    In this hypothetical case, the equation could be implemented as follows:

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

    Best regards.

    Thread Starter rocketpig3

    (@rocketpig3)

    Thanks, I was able to get that to work with a simple field1 – field2 equation.

    How would I make that work with something like this?

    (function(){
    
    if(fieldname1 <= 31) return 26;
    
    if(fieldname1 > 31 && fieldname1 <= 45) return 30;
    
    if(fieldname1 > 45 && fieldname1 <= 60) return 31;
    
    if(fieldname1 > 60 && fieldname1 <= 75) return 34;
    
    if(fieldname1 > 75 && fieldname1 <= 100) return 38;
    
    if(fieldname1 > 100 && fieldname1 <= 200) return 39;
    
    if(fieldname1 > 200 && fieldname1 <= 300) return 42;
    
    if(fieldname1 > 300 && fieldname1 <= 500) return 51;
    
    if(fieldname1 > 500) return 58;
    
    })();

    I tried this but it didn’t work:

    IF(AND(fieldname1|r != '', fieldname2|r != '', fieldname3|r != ''), (function(){
    
    if(fieldname1 <= 31) return 26;
    
    if(fieldname1 > 31 && fieldname1 <= 45) return 30;
    
    if(fieldname1 > 45 && fieldname1 <= 60) return 31;
    
    if(fieldname1 > 60 && fieldname1 <= 75) return 34;
    
    if(fieldname1 > 75 && fieldname1 <= 100) return 38;
    
    if(fieldname1 > 100 && fieldname1 <= 200) return 39;
    
    if(fieldname1 > 200 && fieldname1 <= 300) return 42;
    
    if(fieldname1 > 300 && fieldname1 <= 500) return 51;
    
    if(fieldname1 > 500) return 58;
    
    })();
    Plugin Author codepeople

    (@codepeople)

    Hello @rocketpig3

    Edit the equation as follows:

    
    IF(AND(fieldname1|r != '', fieldname2|r != '', fieldname3|r != ''), (function(){
    
    if(fieldname1 <= 31) return 26;
    
    if(fieldname1 > 31 && fieldname1 <= 45) return 30;
    
    if(fieldname1 > 45 && fieldname1 <= 60) return 31;
    
    if(fieldname1 > 60 && fieldname1 <= 75) return 34;
    
    if(fieldname1 > 75 && fieldname1 <= 100) return 38;
    
    if(fieldname1 > 100 && fieldname1 <= 200) return 39;
    
    if(fieldname1 > 200 && fieldname1 <= 300) return 42;
    
    if(fieldname1 > 300 && fieldname1 <= 500) return 51;
    
    if(fieldname1 > 500) return 58;
    
    })(), '')
    

    Actually, your equation is using only one field, the fieldname1, so, you can verify only its value. Furthermore, the equation’s code can be simplified as follows:

    
    (function(){
    if(fieldname1|r == '') return '';
    if(fieldname1 <= 31) return 26;
    if(fieldname1 <= 45) return 30;
    if(fieldname1 <= 60) return 31;
    if(fieldname1 <= 75) return 34;
    if(fieldname1 <= 100) return 38;
    if(fieldname1 <= 200) return 39;
    if(fieldname1 <= 300) return 42;
    if(fieldname1 <= 500) return 51;
    return 58;
    })()
    

    Best regards.

    Thread Starter rocketpig3

    (@rocketpig3)

    Thanks, I was able to get it to work.

    Is it possible to display a line of text (not input) only when a specific field contains values? I want to display a caveat (“*”) but only once the field has a value, because this will display the “*” suffix. I tried using an HTML block but I wasn’t sure how to set conditions about when it displays.

    Also, for a currency input field, is it possible to display the currency symbol as the user types in values? This can be set for output fields as a prefix but I’m unsure how to do it for an input.

    • This reply was modified 4 years, 4 months ago by rocketpig3.
    • This reply was modified 4 years, 4 months ago by rocketpig3.
    Plugin Author codepeople

    (@codepeople)

    Hello,

    If you want to format the currency fields automatically, tick the checkbox: “Format Dynamically” in their settings. Through the “Currency Symbol” attribute, you can enter the symbol to display in front of the field’s value, and through the “Currency” attribute, enter the symbol or text to display at the end.

    If you want to display some text when a field contains a value, you can use dependencies. If the field is not a calculated field, you should use a calculated field as auxiliary. I’ll try to describe this last case.

    Assuming the input field is the fieldname1.

    Insert an “Instruct. Text” or “HTML Content” field with the text to display, I’ll call it the fieldname2. Furthermore, insert a calculated field that will be used as an auxiliary (you can configure it as hidden by ticking a checkbox in its settings), with the equation:

    IF(fieldname1, 1, 0)

    and then, define dependency in the settings of this calculated field as follows:

    If the value is equal to 1 then select the fieldname2 through the list of dependent fields.

    More information about dependencies, reading the following post in the plugin’s blog:

    https://cff.dwbooster.com/blog/2020/03/01/dependencies/

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Two-stage form (or two forms on one page)’ is closed to new replies.