Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
4

How to create a script for a form

Community Beginner ,
Sep 08, 2023 Sep 08, 2023

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

TOPICS
How to , JavaScript , PDF , PDF forms
584
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2023 Sep 08, 2023

Both fields should have the value 100?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 08, 2023 Sep 08, 2023
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines