Page 1 of 1

onChange event for multiple Fields

Posted: 14 Oct 2020
by slashmaster
Hello,
it is possible to add a onchange for multiple Controls with 1 line code?

fd.field(Field1, Field2, Field3, Field4).change(function() {
alert("Has changed");
});

Thanks in advanced

Re: onChange event for multiple Fields

Posted: 14 Oct 2020
by mnikitina
Hello slashmaster,

No, you need to write code for each field separately. As a workaround, you can create an array with the internal names of all fields on the form and run the code for each field.

Code: Select all

var fields= ['Field1', 'Field2', 'Field3'];

fields.forEach(function(name){
    fd.field(name).change(function() {
         alert("Has changed");
    });
})

Re: onChange event for multiple Fields

Posted: 14 Oct 2020
by slashmaster
Hi mnikitina,

thats awesome! Thank u very much!