Check box that xxports value in one text field to another

New Here ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

Hello, 

I'm redesigning a custom quote sheet for a customer. 

The form is broken down into specific product sections which lists product options in a table with the corresponding price next to it. I am attempting to incorporate a checkbox next to each product field that, when checked, exports the number in the product option's price field to another field. I know this is probably a pretty rudimentary bit of javascript, but I was wondering if anyone could point me in the right direction?

 

Really appreciate your time and any response. 

 

Thanks!

 

TOPICS
JavaScript, PDF forms

Views

81

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
Most Valuable Participant ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

What should happen when the check-box is not ticked? Should the other field be empty? Should it be editable by the user?

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 ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

When the checkbox is not ticked, the second field should be empty. 

I'm trying to eliminate any accidental input from the user, so both of these fields should not be editable by the user. 

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
Most Valuable Participant ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

LATEST

As the custom calculation script of the second text field enter the following (adjust the field names as needed):

event.value = (this.getField("Checkbox1").valueAsString=="Off") ? "" : this.getField("Text1").valueAsString;

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 ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

Lets say first field is named 'Text1' and second field is named 'Text2',
add code to checkbox field as Mouse Up event.It will add value from first field to second if checkbox is checked and it will
remove value from second field if checkbox is unchecked.
this.getField("Text2").value = event.target.value != "Off" ? this.getField("Text1").value : "";

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 ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

Thanks for the javascript!

Unfortunately, I'm having some issues getting this to work properly. When the checkbox is ticked, it deletes the value in the first field and is not adding it to the second. 

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 ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

You don"t need any Javascript.

Put the prices into checkboxes as their "Export value".

In the "total" field just use the "Sum" calculation to make the sum of all checkboxes (in Acrobat's built in calculation, a unchecked checkbox acts as a zero value).

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 ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

Thanks for the suggestion! 

I was hoping that the checkbox would be able to draw from the value in the first box to allow the client to adjust that field when they have price increases throughout the year instead of needing to dive into the checkbox's properties. 

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