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

Repeating text field is not working, cannot find issues with my script.

Community Beginner ,
Jul 08, 2023 Jul 08, 2023

I wanted field Length to populate in field Vanity top length. So I set the field to run a Javascript;

var triggerField = this.getField("Length");
var targetField = this.getField("Vanity top length");
targetField.value = triggerField.value;

This would fill in the field "Length" but would not copy over to the data over to the field "Vanity top length". 

 

So I set up a pop-up to fill in two data fields when a question was answered;

var lengthField = this.getField("Length");
var vanityLengthField = this.getField("Vanity top length");

lengthField.onFocus = function() {
  var vanityLength = app.response("What is the desired vanity top length?");
  if (vanityLength !== null) {
    lengthField.value = vanityLength;
    vanityLengthField.value = vanityLength;
  }
};

Once again, it would not carry the data over to the field "Vanity top length".

So I tried another function, this time putting a script for the field "Vanity top length" to equal "Length".

event.value = this.getField("Length").valueAsString;

 

Still no result. I have checked the spelling to ensure that was not the issue. Now I am unsure where the issue is, so I have attached screenshots to show the form fields are accurately named. Screenshot 2023-07-09 091645.pngScreenshot 2023-07-09 091633.png

Finally, I have attached a copy of the form itself in its current state with the aforementioned Javascript scripts found in said sections.

 

Where have I gone wrong?

TOPICS
General troubleshooting , How to , JavaScript , PDF , PDF forms
562
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
1 ACCEPTED SOLUTION
Community Expert ,
Jul 08, 2023 Jul 08, 2023

Put script in 'Calculate' tab under 'Custom calculation script'.

But for this task it is just simpler to rename "Vanity top length" and give it name "Length", fields with same name will have same value and there is no need for script.

View solution in original post

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 ,
Jul 08, 2023 Jul 08, 2023

Check the JavaScript console for errors.

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 ,
Jul 08, 2023 Jul 08, 2023

Put script in 'Calculate' tab under 'Custom calculation script'.

But for this task it is just simpler to rename "Vanity top length" and give it name "Length", fields with same name will have same value and there is no need for script.

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 ,
Jul 09, 2023 Jul 09, 2023
LATEST

This ChatGPT code is invalid and will not work.

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