Skip to main content
Participating Frequently
July 8, 2023
Answered

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

  • July 8, 2023
  • 3 replies
  • 664 views

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. 

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?

This topic has been closed for replies.
Correct answer Nesa Nurani

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.

3 replies

try67
Community Expert
Community Expert
July 9, 2023

This ChatGPT code is invalid and will not work.

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
July 9, 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.

Bernd Alheit
Community Expert
Community Expert
July 9, 2023

Check the JavaScript console for errors.