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

Link Checkbox to text field output

TrishM
Registered: Oct 5 2010
Posts: 6
Answered

I am just learning how to program forms in Acrobat 9.0 and I am having trouble linking a checkbox to the output in a specific field. Example: I have the names of two different agent fields on a transaction. One represents a buying agent and one represents a selling agent. When I click on a checkbox under "Seller" I want the Selling Agent info to be pulled into the text field in question, if I click "Buyer" I want the Buying Agent info pulled into the text field. I have had experience with javascript but am having problems finding a code that will work. Any help would be appreciated.

My Product Information:
Acrobat Pro 9.3.1, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2399
Pulled from where, exactly?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

TrishM
Registered: Oct 5 2010
Posts: 6
okay I have it set up like this:

Field Box 1 = Agent Name
Field Box 2 - Agent Name

Check Box 1 - Represents Sellers
Check Box 2 - Represents Buyer
Check Box 3 - Represents Both

Field Box 3 = Results

I need field box 3 to represent the correct agents name depending on which checkbox is marked. so if checkbox 1 is checked it will show the contents of Box 1, if check box 2 is checked it will pull the information from box 2, etc.

Thanks so much for any help!
try67
Expert
Registered: Oct 30 2008
Posts: 2399
You can place this code as the custom calculation script of Field Box 3:

event.value = "";
if (this.getField("Check Box 1").value == "Yes") {
event.value = this.getField("Field Box 1").value;
}
if (this.getField("Check Box 2").value == "Yes") {
event.value = this.getField("Field Box 2").value;
}

I'm not sure what you want to do if both are checked. Also, I recommend you use radio-buttons instead of check-boxes.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Since the check boxes are mutually exclusionary, you can give them all the same name and then each check box would have a unique "export value". This eliminates the need to code for having only one check box checked at a time. You will have a check box name like 'Check Box 1' and each different occurrence would have a different 'export value'.

You could then have a 'custom calculation script' in 'Field Box 3' of:

event.value = this.getField("Check Box 1").value;
// if value is "Off" then clear the field
if (event.value == "Off") event.value = "";


And as each instance of the check box is checked, any other check box for the group that is checked will become unchecked. If the checked box is selected it will become unchecked.

George Kaiser

TrishM
Registered: Oct 5 2010
Posts: 6
Thank you both so much. It worked both ways! Thanks again