Combine two values into one field

Hello,
I have two dropdown value fields ('Week' and 'Position'). When the values are selected in these two fields, i'd like to combine them into one field called 'PositionWeek'.

How do I do this? Thanks!

Hello @ParAvion,

You can use the below code to combine values from the drop-down fields. Please make sure that you are using the internal names of the fields in the code.

fd.spRendered(function() {

    function combine () {

        if (fd.field('Week').value != null && fd.field('Position').value != null) {

            fd.field('PositionWeek').value = fd.field('Week').value + ' ' + fd.field('Position').value;
        }

        else {
            //Clear PositionWeek field value if one of the dropdowns is cleared
            fd.field('PositionWeek').value = '';
        }
    }
    //Call function on form load
    combine ();

    //Call function on field change
    fd.field('Week').$on('change', combine);
    fd.field('Position').$on('change', combine);

});
1 Like