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

Auto update textbox values from another field value not working

New Here ,
Aug 30, 2018 Aug 30, 2018

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
7.5K
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 ,
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.

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

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

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

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

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

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;

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

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?

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

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?

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

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

If not, can you share the file in question?

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

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

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

What are the names of the fields involved?

The way you shared the file is fine.

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

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

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

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

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

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

Untitled.png

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

This is not available in the shared file.

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

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

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 ,
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.

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

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