These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Help please: Check box to return value from another field

Mbutterworth
Registered: Jan 27 2010
Posts: 2

Hi and thanks for reading this.

I'm new to LiveCycle and have a problem that no doubt has a simple answer...

Scenario

I have a Text Field called InvoiceAddress.
I have a Check Box called SameAsInvoiceAddress
I have a 2nd Text Field called InstallationAddress

I want the InstallationAddress TextField to be populated with the value from the InvoiceAddress Text Field when the SameAsInvoiceAddress Check Box is checked. When it isn't checked I want the field to remain blank so the user can type in a manual InstallationAddress.

(I've done my other formulas using FormCalc)

Thank you in advance.

Matt

My Product Information:
LiveCycle Designer, Windows
pforms
Registered: Nov 17 2009
Posts: 87
If you haven't solved this, I have a similar sample I can email.
It's a billing/shipping address checkbox that you can modify
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This is a tricky one. You can easily create a button that copies values from one set of fields to the other. But this is a one time operation and it sounds like you need the data to be automatically copied (continously) when the check box is checked. The best solution is to use a calculation script in the InstallationAddress fields to aquire the values from the InvoiceAddress fields.

The trick of course is to get the copy to turn off when the check box is unchecked. Here's a script that should be placed in the Mouse Up event for the check box. It will turn calculations on and off in the InstallationAddress field.
if(this.rawValue){// field is copied, turn calculation onInstallationAddress.access = "readOnly";InstallationAddress.calculate.override = "error";InstallationAddress.value.setAttribute("0","override")InstallationAddress.execCalculate();}else{// Field is user entered, turn calcualtions offInstallationAddress.access = "open";InstallationAddress.calculate.override = "disabled";InstallationAddress.value.setAttribute("1","override")}

Of course you want to start off with the field set for user entry, so place this script in the Initialize event of the InstallationAddress field.
this.calculate.override = "disabled";this.value.setAttribute("1","override")

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

oksana77
Registered: Apr 24 2009
Posts: 89
I am trying to incorporate the above code into my form. I have a subform where you can add and delete instances, a subtotal field which adds up the subform fields, tax rate field and sales tax field. If the tax rate is 0, the user can override the sales tax; otherwise, it is calculated. When calculation script is enabled, the subtotal is adjusted every time a new instance is created or deleted. However, if the calculation script is disabled, the value I entered for sales tax will disappear every time a new instance of the subform is added.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Don't disable the calculation, make it conditional instead so that the calculations flow as normal, but the result in the tax field is set to zero.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

lorimevans
Registered: Apr 1 2011
Posts: 2
pforms wrote:
If you haven't solved this, I have a similar sample I can email.
It's a billing/shipping address checkbox that you can modify
I would like to see the sample please. I am encountering a similar problem. Found out the scripts for a same billing/shipping check box are different if using LiveCycle Designer.
pforms
Registered: Nov 17 2009
Posts: 87
Stripped down version:

textfield named address - labeled on the form as Billing Address

Check box labeled "same as billing"

Textfield named address - labeled Shipping

Binding set for Global on the 2 address fields.

On the checkbox click:

if ($.rawValue==1)then
form1.button.presence="visible"
else form1.button.presence="hidden"
endif