How to make a Onchange client script for when any form field changes and not a particular one?

Community Alums
Not applicable

Hello! I need to make a Onchange client script for when any form field changes and not a particular one? I configured the client like this leaving the Variable Name field blank but the client script doesn't fire. Any ideas? 

Rocio_0-1679419780330.png

 

3 REPLIES 3

DrewW
Mega Sage

The system does not support this OOB.  The only think you can do is create a UI script that has a function in it that does whatever the work is and then create a onChange script that calls that function.  There are some other options that are way more complicated and require DOM manipulation and I do not recommend those.

You could request this in an Idea on the Idea portal if its not already out there.

 

Daniel Gens
Tera Contributor

Hi,

 

For anyone who comes across this post through search engines, I was able to set up an onLoad Client Script that listens to any field changes by registering a handler using g_form.onUserChangeValue() .

 

 

function onLoad() {
	var handler = function (fieldname, originalValue, newValue) {
		g_form.showFieldMsg(fieldname, 'Old val: '+ originalValue + '\nNew val: ' + newValue, 'info');
		if (fieldname == 'category') {
			//do something
		}
	};
	g_form.onUserChangeValue(handler);
}

 

 

 

Nice to know they added something for this.