Help for fix script to populate ship to fields when I click same as above

New Here ,
Mar 16, 2021 Mar 16, 2021

Copy link to clipboard

Copied

Hi, in the attach pdf form. I've 3 fields in customer details section:

1. name

2. address

3. address2

I want to auto populate data from this 3 fields to "Ship to" section (bellow fields) if I click "SameAsAbove" checkbox:

1. Nameofshipping

2. Addressofshipping

2. Address2ofshipping

 

I've added bellow script in the chckbox field<Action<Mouse Up<Ran a Javascript&colon;

 

// check the state of the buttonif(this.getField(event.target.name).value == 'Yes') {// checked// copy address information// get each billing field object's value and set the shipping field's valuethis.getField('name').value = this.getField('nameofshipping').value;this.getField('address').value = this.getField('Addressofshipping').value;this.getField('Address2').value = this.getField('Address2ofshipping').value; // lock fields// set each shipping field's read only property to locked - truethis.getField('name').readonly = true;this.getField('address').readonly = true;this.getField('Address2').readonly = true;} else {// unchecked// unlock fields// set each shipping field's readonly property to unlocked - falsethis.getField('name').readonly = false;this.getField('address').readonly = false;this.getField('Address2').readonly = false;}

 

But the fucntion is not working. anyone could help me in this regard. BTW I've no idea about writing java script. However thanks in advance

 

 

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF forms

Views

270

Likes

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

Adobe Community Professional , Mar 17, 2021 Mar 17, 2021

Change the field calculation order.

Likes

Translate

Translate
Adobe Community Professional ,
Mar 16, 2021 Mar 16, 2021

Copy link to clipboard

Copied

Try this code:

if(event.target.value != "Off"){
this.getField("Nameofshipping").value = this.getField("Name").value;
this.getField("Addressofshipping").value = this.getField("Address").value;
this.getField("Address2ofshipping").value = this.getField("Address2").value;
this.getField("Nameofshipping").readonly = true;
this.getField("Addressofshipping").readonly = true;
this.getField("Address2ofshipping").readonly = true;}
else {
this.getField("Nameofshipping").value = "";
this.getField("Addressofshipping").value = "";
this.getField("Address2ofshipping").value = "";
this.getField("Nameofshipping").readonly = false;
this.getField("Addressofshipping").readonly = false;
this.getField("Address2ofshipping").readonly = false;}

Likes

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 ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

it worked! Thanks a lot. But having onother problem. Sometimes calculation fields not working properly in this form. I've made a screen record of that problem: https://www.screencast.com/t/l6liUXgvPN

I've attached the form here could you help that will be great. 

Likes

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 ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

Likes

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
Adobe Community Professional ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

Change the field calculation order.

Likes

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 ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

Thanks for your reply Bernd Alheit. I tried to reorder. here is the order of calculation fields: https://www.screencast.com/t/ASj0CFHVuBq

But still "subtotal" field not showing the value of 1st row. when I enter value in 2nd row then it show the result: https://www.screencast.com/t/cXiURSfucY

thanks in advance.

Likes

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
Adobe Community Professional ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

The picture shows the tab order, not the field calculation order.

Likes

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 ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

Sorry, actually I'm new user of calculation fields. I thought you told me about fields order. Here is the calculation script. It's in order and the fields also: https://www.screencast.com/t/xNmE8qUAooK

Still having the problem.

 

Likes

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 ,
Mar 17, 2021 Mar 17, 2021

Copy link to clipboard

Copied

Not I got it Thanks a lot.

Likes

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 ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

what is the "event.target.value" ... and where does that go on the form itself?

Is this the name used for the "same as above checkbox" or should we use a BUTTON instead?

 

I have a very similar task where the client fills out there address info in the top table of fields and, if the top address is same as the next one down, they can autopopulate those fields based on the previous inputs above using the CHECK BOX on ... hope this makes sense.

 

Woody House

Likes

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 ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

I am attaching a screenshot of my actual PDF in production ...

 

You should see 3 tables of fields where we collect the user's address details ... the logic here is:

 

They ALL fill out the top field in all cases

If the first table with fields has the same address specs, they use the checkbox above that table to auto populate

If the second table with fields has the same address specs as the first table NOT the top table ... they check that box to auto populate

 

Nesa's basic script is working but we have two checkboxes to contend with here ...

 

Thanks heaps!

Likes

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 ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

LATEST

Solved ... using this for the checkbox logic:

 

if (this.getField("Checkbox1").isBoxChecked(0)) {

Likes

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 ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

Dear Nesa ...

Your script worked for me first time ... amazing!

However, what if they want to clear that entry ... if they TOGGLE OFF the checkbox, is there a way to reverse the auto fill of the fields like using a RESET functionality perhaps?

 

Thanks heaps

Woody House

City of Hamilton

Digital Forms Developer

Likes

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