Copy link to clipboard
Copied
Originally posted in the InDesign forum by mistake:
I'm a complete novice at script writing and am attempting to force 2 fields in a form to always equal 100. I got the script below from a ChatGPT application, but it doesn't work. I'm not sure why, but I know I'm doing something wrong. First of all, do I enter this (or a better script) into the properties of both fields or just one of them? And second, does anyone know a way to make this work?
var field1 = this.getField("Field1"); var field2 = this.getField("Field2"); field1.setAction("Calculate", "event.value = 100 - getField('Field2').value;"); field2.setAction("Calculate", "event.value = 100 - getField('Field1').value;");
Copy link to clipboard
Copied
Both fields should have the value 100?
Copy link to clipboard
Copied
The two fields should add up to 100. It's a percentage of money being taken from different accounts so it has to always equal 100.