onChange event for multiple Fields

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
slashmaster
Posts: 29
Joined: Fri May 25, 2018

14 Oct 2020

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

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

14 Oct 2020

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");
    });
})

slashmaster
Posts: 29
Joined: Fri May 25, 2018

14 Oct 2020

Hi mnikitina,

thats awesome! Thank u very much!

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 15 guests