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

Auto update textbox values from another field value not working

New Here ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Hi All,

I'm sorry if I've not found an existing post that may resolve this issue. I've spent days researching and trying different variations but nothing seems to work. I'm new into using PDF and javascript so I'll try to be as clear and basic as I can. It's likely I'm not using "prepare forms" for it's intended use but I'm hoping there's a workaround.

I'm creating a fillable document and I need to have the details of one-page (Customer and Company Details) update the details of a few other pages within the whole document to avoid duplication and to save the time of the salesperson.

For example, on the first page we are completing "Enquiry - Company Name" (Textbox) and then on the 2nd page, the text box "Survey - Company Name" would automatically populate with the "Enquiry - Company Name" value and so on and so on through the document.

I've tried some of the following options: either through an "On Blur" Javascript option or a "Custom Keystroke Script" but nothing seems to work.

var n1 = this.getField("Enquiry - Company Name");

var n2 = this.getField("Survey - Company Name");

n2.value = n1.value;

this.getField("Survey - Company Name").value = this.getField("Enquiry - Company Name").value;

event.value = this.getField("Enquiry Pad – Business Name).value;

Any help would be greatly appreciated.

Thanks

Gary

TOPICS
PDF forms

Views

7.0K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Aug 30, 2018 Aug 30, 2018

Now it's there, and as soon as you edit the value of any field this error message appears:

TypeError: this.getField("Enquiry Pad \u2013 Business Name") is null

1:Field:Calculate

This means you used the wrong field name, most likely do to the non-standard hyphen in the middle.

Don't use something like Word to edit the code, only a plain-text editor, like Notepad.

Votes

Translate

Translate
Community Expert ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Simply give both fields the same name and they'll have the same value automatically...

Votes

Translate

Translate

Report

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
New Here ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Hey try67,

oh my, I didn't think it would be so simple. However, it does cause another issue for me in that I wanted to protect the other fields on the other pages from being edited and as they are now "technically" the same field it's not going to allow me to do that. Is there another way around this?

Thanks again 🙂

Gary

Votes

Translate

Translate

Report

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 ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Yes. Let's say you want to copy the value from Text1 to Text2. Use this code as the custom calculation script of Text2:

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

Votes

Translate

Translate

Report

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
New Here ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

I've added that line into the custom calculation script of the text2 but upon completing text 1 and either clicking, tabbing or clicking away from that text1 field, text2 doesn't update as expected.

Any idea's what's stopping it?

Votes

Translate

Translate

Report

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
New Here ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Just to add to the above, I've tried this is a new blank document and it works fine, so there is something definitely stopping that from working.

The only part I can think that it might be is that I've got a combo box that is running a separate javascript that updates a textbox with pre-defined values from a Javascript document.

Would that make the difference?

Votes

Translate

Translate

Report

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 ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Is it updating the same field? If so, it will be a conflict, of course.

If not, can you share the file in question?

Votes

Translate

Translate

Report

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
New Here ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

No the other fields that have the javascript document are 2 unrelated fields to things like a contact name and business name which is why I'm still confused.

https://1drv.ms/b/s!AvmCmkb3rUqvsXixw_ayBWt8ndk6

Above is a link to the file, hopefully, it will work not sure how to attach documents :-s

Votes

Translate

Translate

Report

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 ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

What are the names of the fields involved?

The way you shared the file is fine.

Votes

Translate

Translate

Report

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
New Here ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

The 2 that I'm starting with are

Enquiry Pad - Business Name

App Survey - Company Name

But there will be more through the document such as:

Customer Name & App Survey - Contact Name.

Thx

Votes

Translate

Translate

Report

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 ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

I don't see that you applied a calculation code to any of these fields...

Votes

Translate

Translate

Report

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
New Here ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

That's strange, it's definitely there, please see below.

Untitled.png

Votes

Translate

Translate

Report

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 ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

This is not available in the shared file.

Votes

Translate

Translate

Report

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
New Here ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Hi Bernd,

I'm not sure why as per the screenshot it's showing it for me. I've re-saved the file and if you try this link it will be in there now.

https://1drv.ms/b/s!AvmCmkb3rUqvsXixw_ayBWt8ndk6

As mentioned, the line of the script, I've already tried and it works in a blank document, but for some reason, something is stopping it in my document.

Thanks

Votes

Translate

Translate

Report

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 ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

Now it's there, and as soon as you edit the value of any field this error message appears:

TypeError: this.getField("Enquiry Pad \u2013 Business Name") is null

1:Field:Calculate

This means you used the wrong field name, most likely do to the non-standard hyphen in the middle.

Don't use something like Word to edit the code, only a plain-text editor, like Notepad.

Votes

Translate

Translate

Report

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
New Here ,
Aug 30, 2018 Aug 30, 2018

Copy link to clipboard

Copied

LATEST

The textbox names I've typed in myself and included the "-" as a separator between the page name and the textbox name to help further down the line.

I've used Word to copy and paste but the "-" was already there, I've removed this from the textbox name and updated the script and it's now working perfectly.

Thank you so so much!!!

Votes

Translate

Translate

Report

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