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

nested "if" statement syntax with action to place a value into field

mbush
Registered: Oct 13 2008
Posts: 6

I have a table of shipping and handling costs identified to a range for total amount purchased. For example, if a customer purchases a total dollar value between 1 cent and $30, shipping and handling will cost $7.50, if between $30.01 and $45, then $8.50, if between $45.01 and $95, then $9.50, and if => $95.00, then $10.50. Based upon the code that follows, I have something wrong with my syntax and getting it to move a shipping and handling value into the field. My attempt at the code needed is as follows:

if (Total of Page 2 > 0 && Total of Page 2 <= 30.00) {event.value = 7.50};
if (Total of Page 2 > 30.00 && Total of Page 2 <= 45.00) {event.value = 8.50};
if (Total of Page 2 > 45.00 && Total of Page 2 <= 95.00) {event.value = 9.50};
if (Total of Page 2 > 95.00) {event.value = 10.50};

Thank you for your help!

My Product Information:
Acrobat Standard 5.x or older, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
You will have the get the value that is in your "Total of Page 2" field and use it in your script. For example, if the field is named "Total2", the field's custom calculation script might be:

//Get total of page 2 value, as a numbervar t2 = +getField("Total2").value; // Set default shipping & handling valuevar sh = ""; if (t2 > 0 && t2 <= 30) sh = 7.5;if (t2 > 30 && t2 <= 45) sh = 8.5;if (t2 > 45 && t2 <= 95) sh = 9.5;if (t2 > 95) sh = 10.5; // Set this field's valueevent.value = sh;

Replace "Total2" above with the actual name of your field.

George