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!
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?
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.
Copy link to clipboard
Copied
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;
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 : "";
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.
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).
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.