Skip to main content
Participating Frequently
September 8, 2023
Question

How to create a script for a form

  • September 8, 2023
  • 1 reply
  • 774 views

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

This topic has been closed for replies.

1 reply

Bernd Alheit
Community Expert
Community Expert
September 8, 2023

Both fields should have the value 100?

Participating Frequently
September 8, 2023

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.