Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Using a check box to autopopulate other fields (bill to = ship to)

Avatar

Level 1

I've checked other threads and am not sure what I need to do.

I have ZERO scripting experience and am using LC Designer ES 8.2.

The form I designed will eventually be sent to our customers for them to fill out using Adobe Reader.

I have two sections - one is "bill to" and one is "ship to" and they are free text areas with one drop down for "country".

What I want to do is put a check box on the form that says "Bill to is the same as ship to".

If the user clicks the box, the data should autopopulate the other fields.  If they "un-click" the box, the data goes away.

Scripting is WAY over my head and scares me but I can follow directions.

Can anyone help me?

1 Accepted Solution

Avatar

Correct answer by
Level 6

Chuck,

First off do not apologize for asking a question...no question is stupid.

Secondly, the script for your checkbox is on the wrong event.  In looking at your screenshot, you placed it on the "click" event...it should be place on the "change" event. See screen shot below.

Then, the script should be (for example):

if (this.rawValue == 1){

Company2.rawValue = Company1.rawValue;

}

if (this.rawValue == 0){

Company2.rawValue = "";

}

Lastly, this is just a suggetion...  Since you are making the check box (Same As Ship To...meaning the Bill To info would be the same as the Ship To info) I would make the "Bill To" column the second column, and make the ShipTo the first column so users  enter the Ship To info first. In my example, Company1 represents the ShipTo,a nd Company 2 represents BillTo. When the users checks the box (check box value == 1), the billto info is populated by the ship to info entered data, and when unchecked (checkbox value == 0), the billto fields become empty...hence (Company2.rawValue = "";)

event script.jpg

View solution in original post

5 Replies

Avatar

Level 6

If you use Javascript language you can add this to the "change event" for the checkbox...

if (this.rawValue == 1){

BillToField1.rawValue = ShipToField1.rawValue;

BillToField2.rawValue = ShipToField2.rawValue;

[...continue this for all the applicable fields, setting each BillTo field to match/equal to the corresponding ShipTo field]

}

//the script above tells the form what to do if the check box is checked (i.e. default value equals 1 when checked)

if (this.rawValue == 0){

BillToField1.rawValue = "";

BillToField2.rawValue = "";

[...]

}

//the script above now tells the form what to do if the check box is unchecked (i.e. default value equals 0 when unchecked). In htis case, the BillTo fileds will equal null or blank which is what "" represents.

//If needed, you can switch the fields to so that they read:

ShipToField1.rawValue = BillToField1.rawValue;

This way the ShipTo field values are taken from the user entered BillTo fields.

I should note that you must name th fields to match the scripting names, specifically.

Hope this helps.

Avatar

Level 1

Thanks for your response.

Based on your reply, I've entered this -

if (this.rawValue == 1){

Company1.rawValue = Company2.rawValue;

Contact1.rawValue = Contact2.rawValue;

Phone1.rawValue = Phone2.rawValue;

Email1.rawValue = Email2.rawValue;

Address1-1.rawValue = Address2-1.rawValue;

Address1-2.rawValue = Address2-2.rawValue;

Address1-3.rawValue = Address2-3.rawValue;

City1.rawValue = City2.rawValue;

ZipCode1.rawValue = ZipCode2.rawValue;

Country1.rawValue = Country2.rawValue;

}

and when I clcik the check box in the Preview PDF pane, nothing happens.

Do I have to save this as a "reader enabled" file before I can check to see if it works?  Our clients that receive this form will be filling it out using Adobe Reader.

I'm only focused on the first two columns for now.  I may eventually add the "End User" column down the line, but I just want to get the first part working first.

LC_checkbox.JPG

Company1 corresponds to the binding value in the "Company" field in the first column (Invoice or Bill To).  Company2 corresponds to the binding value in the "Company" field in the "Ship To (from freight forwarder)" in the second column.  This is the same pattern all the way through.

In the address fields, the binding values are shown as as follows -

Address1-1 means column 1, field 1

Address1-2 means column 1, field 2

Addrress1-3 means column 1, field 3

Etc...

I think I need to change the binding value for each field as I don't think the script like the "dash" in the binding values of the address fields.

Again, I'm sorry for these are stupid questions, but I am completely uneducated and green when it comes to using scripts.

Avatar

Correct answer by
Level 6

Chuck,

First off do not apologize for asking a question...no question is stupid.

Secondly, the script for your checkbox is on the wrong event.  In looking at your screenshot, you placed it on the "click" event...it should be place on the "change" event. See screen shot below.

Then, the script should be (for example):

if (this.rawValue == 1){

Company2.rawValue = Company1.rawValue;

}

if (this.rawValue == 0){

Company2.rawValue = "";

}

Lastly, this is just a suggetion...  Since you are making the check box (Same As Ship To...meaning the Bill To info would be the same as the Ship To info) I would make the "Bill To" column the second column, and make the ShipTo the first column so users  enter the Ship To info first. In my example, Company1 represents the ShipTo,a nd Company 2 represents BillTo. When the users checks the box (check box value == 1), the billto info is populated by the ship to info entered data, and when unchecked (checkbox value == 0), the billto fields become empty...hence (Company2.rawValue = "";)

event script.jpg

Avatar

Level 6

Also, there is no need to setting binding for these fields if oyu are using the sample script provided.  Binding will only work if the field names are the "same" and oyu set the binding for the field to "global". Doing so will make the value for all fields, with the same name, the same value. This is not what you want.  You want to control it via the check box. At least that's what I presume you are looking to achieve.

Avatar

Level 1

I could not have asked for a better answer!  I did exactly what you said and it works great!

Thank you so much for spending the time to explain this to me.

Unfortunately, I can't change the order of the columns so I have to have "Bill To" as the first column and "Ship To" as the second columns.  it's just one of those "corporate" things I have to comply with.

*high five*

Thanks again!