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

How do I Move a value to Total Column when I click in the Check Box

hughesr
Registered: Dec 18 2008
Posts: 7

I am new to Adobe 9 and I believe that I should be able to perform the following:

I have 3 columns

Column 1 is a check box, column 2 a Dollar Value, column 3 currently blank, but as I select items with the check box I want the dollar value from column 2 show up in column 3. As items are selected column 3 will total.

I have figured out how to do the total of column 3, what I have not figured out how to do is copy the value from column 2 to column 3 when I select the item with the check box.

If I need Java Script, I would appreciate receiving the required script as I do not program in Java.

Thank you

My Product Information:
Acrobat Pro 9.0, Windows
hughesr
Registered: Dec 18 2008
Posts: 7
Update, the value in column 2 is set as the default value for that field. I then set formating to dispay as a dollar value.

Also, if the remove the check mark I would need to clear the value in column 3 so that the total of column 3 is always correct in relation to the items selected.

Thank you
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
If you set up the field in column 3 as a calculated field, you can use the following as its custom calculate script:

(function () { // Get the value of the check boxvar v1 = getField("Check1").value; // Set this field's value to the value of the text box in column 2// if the check box is checkedif (v1 !== "Off") {event.value = getField("Text2").value;} else {// Blank this field if check box is uncheckedevent.value = "";}})();

You'd have to replace "Check1" and "Text2" in the code above to match the names of your fields, but you should get the idea.

If you have a number of rows, this would best be implemented as a document-level function that you could generalize so that it could be used for the column 3 field of each row.

There are a number of articles here (JavaScript Corner) by Thom Parker that discuss JavaScript programming, from the basic to more advanced. They are a great resource to begin learning more. Or you could pay someone to do it for you.

George
hughesr
Registered: Dec 18 2008
Posts: 7
I copied the entire script above into the Column 3. I then ran the form and it did not work.

Column 1 is called LTR1Check
Column 2 is called LTR1Amount - Read Only
Column 3 is called LTR1Fee - Read Only

Is there something I need to do to trigger this? I click on the check box then hit tab to move to the next filed, which ends up being

LTR2Check as LTR1Amount and LTR1Fee are read-only fields.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Based on that, the correct custom calculation script for the field in column 3 would be"

(function () { // Get the value of the check box in column 1var v1 = getField("LTR1Check").value; // Set this field's value to the value of the text box in column 2// if the check box is checkedif (v1 !== "Off") {event.value = getField("LTR1Amount").value;} else {// Blank this field if check box is uncheckedevent.value = "";} })();

This code will get triggered whenever any field value changes, which will happen when the check box is toggled.

George