Show Fields based on cost value more than 50,000

Hi,

I have tried researching and cannot find any code that will help me in creating a function on a form.

For anyone reading this I would really appreciate your help.

In Plumsail Public Form; I have 2 fields that have been added to the form with no extra customisation (AP5 Name, AP5 Email).

I only want the AP5 fields to appear if the value in the Total Cost field (no customisation on field) is more or equal to 50,000.

Can someone please provide me with the coding for this.

Regards

Hello @melo,

Please see the code example:

fd.rendered(function() {

    function hideOrShowField() {
        if (fd.field('Total').value >= 50000) {
            // Show fields
            fd.field('AP5Email').hidden = false;
            fd.field('AP5Name').hidden = false;
        } else {
            // Hide fields
            fd.field('AP5Email').hidden = true;
            fd.field('AP5Name').hidden = true;
        }
    }

    // Calling hideOrShowField when value changes
    fd.field('Total').$on('change',hideOrShowField);

    // Calling hideOrShowField on form loading
    hideOrShowField();

});

Make sure you use internal names of the fields in the code.

Please see JavaScript framework - Manage fields article for more examples.

1 Like

Hi @mnikitina ,

Thank you for getting back to me.

I managed to figure out the code myself before receiving your reply but thank you anyway.

At least now there is a thread for it to help people in the future.

Have a nice day.

Regards