How to create a script for a form
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;");
