Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Ship to and Bill to the same

Avatar

19-02-2009

Thanks for all the wonderful tips and tricks here...I've learned a lot. I am trying to create a check box that will automatically transfer the "Ship to" to the "Bill to" if the are the same. I can't seem to figure it out.



Here is an example:

http://www.wizzardweb.co.uk/java_copy_info.html



I've used the following code but to no avail:



var ShipToCompany = "";

var ShipToContact = "";

var ShipToAddress = "";

var ShipToCityStateZip = "";

var ShipToPhone = "";

var ShipToEmail = "";



function InitSaveVariables(form1) {

ShipToCompany = form1.ShipToCompany.value;

ShipToContact = form1.ShipToContact.value;

ShipToAddress = form1.ShipToAddress.value;

ShipToCityStateZip = form1.ShipToCityStateZip.value;

ShipToPhone = form1.ShipToPhone.value;

ShipToEmail = form1.ShipToEmail.value;

}



function infoCopy(form1) {

if (CheckBox1.copy.checked) {

InitSaveVariables(form1);

form1.ShipToCompany.value = form1.BillToCompany.value;

form1.ShipToContact.value = form1.BillToContact.value;

form1.ShipToAddress.value = form1.BillToAddress.value;

form1.ShipToCityStateZip.value = form1.BillToCityStateZip.value;

form1.ShipToPhone.value = form1.BillToPhone.value;

form1.ShipToEmail.value = form1.BillToEmail.value;

}

else {

form1.ShipToCompany.value = ShipToCompany;

form1.ShipToContact.value = ShipToContact;

form1.ShipToAddress.value = ShipToAddress;

form1.ShipToCityStateZip.value = ShipToCityStateZip;

form1.ShipToPhone.value = ShipToPhone;

form1.ShipToEmail.value = ShipToEmail;

}

}



Any help would be great appreciated.

Replies

Avatar

Avatar
Validate 1
Level 9
Steve_L_Walker
Level 9

Likes

197 likes

Total Posts

1,435 posts

Correct Reply

212 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 9
Steve_L_Walker
Level 9

Likes

197 likes

Total Posts

1,435 posts

Correct Reply

212 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
Steve_L_Walker
Level 9

20-02-2009

First, you are using the 'value' property and you should be using the 'rawValue' property. Second, if a user has entered data into the Ship To form fields you don't need to create new variables to store them.



Here is the click event on my checkbox object called 'copy', where the checkbox has an On Value of 1 and an Off Value of 0.



if (this.rawValue == "1") {

form1.subform1.billToCompany.rawValue = form1.subform1.shipToCompany.rawValue;

form1.subform1.billToAddress.rawValue = form1.subform1.shipToAddress.rawValue;

form1.subform1.billToCity.rawValue = form1.subform1.shipToCity.rawValue;

}



Steve

Avatar

20-02-2009

Steve thanks for getting me started and the clarification. Still cannot get the data to move over. I think I'm over looking something.



form1.#subform[0].subform.CheckBox1::click - (JavaScript, client)



if (this.rawValue == "1") {

form1.subform1.BillToCompany.rawValue = form1.subform1.ShipToCompany.rawValue;

form1.subform1.BillToContact.rawValue = form1.subform1.ShipToContact.rawValue;

form1.subform1.BillToAddress.rawValue = form1.subform1.ShipToAddress.rawValue;

form1.subform1.BillToCityStateZip.rawValue = form1.subform1.ShipToCityStateZip.rawValue;

form1.subform1.BillToPhone.rawValue = form1.subform1.ShipToPhone.rawValue;

form1.subform1.BillToEmail.rawValue = form1.subform1.ShipToEmail.rawValue;

}

Avatar

Avatar
Validate 1
Level 9
Steve_L_Walker
Level 9

Likes

197 likes

Total Posts

1,435 posts

Correct Reply

212 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 9
Steve_L_Walker
Level 9

Likes

197 likes

Total Posts

1,435 posts

Correct Reply

212 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
Steve_L_Walker
Level 9

20-02-2009

If you do not have a subform called subform1 than these fully-qualified object names will not work.



You can either



1. change the subform names in the script to match your subform name

2. reference the fields without the form and subform prefix, or

3. if the subform is untitled use the syntax form1.#subform[0].BillToCompany.rawValue, for example.



Steve

Avatar

Avatar
Validate 1
Level 10
Niall_O_Donovan
Level 10

Likes

646 likes

Total Posts

4,352 posts

Correct Reply

786 solutions
Top badges earned
Validate 1
Boost 500
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 1
Level 10
Niall_O_Donovan
Level 10

Likes

646 likes

Total Posts

4,352 posts

Correct Reply

786 solutions
Top badges earned
Validate 1
Boost 500
Boost 50
Boost 5
Boost 3
View profile
Niall_O_Donovan
Level 10

21-02-2009

Hi TF,



A tip from JP Terry's (excellent) book!



When in the script editor you can hover over the field you want to reference. Pressing control will turn the cursor into a down arrow, then holding control and clicking the field will insert the object's reference directly in your script:

BillToCompany



If you hold control and shift, you will get a fully qualified reference:

xfa.resolveNode("xfa.form.form1.#subform[0].BillToCompany")



Try it out, as it helps ensure that the references are correct.



N.