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

Formula based on invoice case count

atlbananas
Registered: Dec 2 2008
Posts: 6

What's up all,

I have a PDF that we fill out for a vendor at my work. Basically, we deliver some products for them and depending on the amount of cases we deliver, we charge a certain amount. For instance, 4 cases is $16.00 and 7 cases is $40.00. Currently, when we fill the form out, we list how many cases we delivered and we look at a handwritten cheat sheet to know how much the cost is for that delivery. I would like for this to be in the PDF form itself. This way it will eliminate mistakes and speed up the time it takes to fill this thing out. Can anyone help me out??? Thanks!!!!

My Product Information:
Acrobat Pro 8.0, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Yes, you will have to use Acrobat JavaScript or FormCalc to total the number cases and either calculate or lookup the amount of the shipping. The exact answer will depend upon if you are using Acrobat's FormTool or LiveCycle Designer and how the shipping cost are determined.

George Kaiser

atlbananas
Registered: Dec 2 2008
Posts: 6
Oops. I'm using Acrobat's Form Tool. Could you give me an example of one way to do this? The last I've ever used this stuff was back in 1999 in an Intro class. I don't remember any of this!?!?! Thanks for the quick response!!

PS- Do you know why the date on my profile is saying 1969?? Very weird.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Assuming you have not created your form fields.

I would use hierarchical field names, see [url=http://www.planetpdf.com/developer/article.asp?ContentID=acrobat_pdf_forms_a_step_by_s&gid=6480]Acrobat PDF Forms: A Step-by-step Introduction[/url] by Ted Padova for and example. And you have a series of fields named "case.0", "case.1", ... and you have a field for the total case count called "totalCase". You can have a "Custom Calculation Script" for this field of:
function SumFielObject(oField) {var sum = 0; // variable for computed sumvar aField = oField.getArray(); // convert case object to an array// loop through the fields in case arrayfor (i = 0; i < aCase.length; i++) {sum += Number(aCase[i].value); // add each element of array}return sum; // return the calculated sum} // end function // set field value to the some of the case field objectevent.value = SumFielObject(this.getField("case") );

And a field called 'shipping' would have a custom calculation script of:

// get total number of casesvar fTotalCase = this.getField("totalCase").value;// takes action when comparison is trueswitch(true) {// zero or less casescase (fTotalCase <= 0):event.value = 0;break;// to 5 casescase (fTotalCase <= 5):event.value = 16;break;// 6 to 10 casescase (fTotalCase <= 10):event.value = 40;break;// 11 to 15 casescase (fTotalCase <= 10):event.value = 50;break;// all other valuesdefault:event.value = '';app.alert("Please contact us for pricing");break;} // end of selection

George Kaiser