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

Changing Shipping Charges in Custom Calculation

ontarioblockparent
Registered: Feb 16 2010
Posts: 16
Answered

I have a resource materials order form.

I have all the Quantity and Unit prices multipling to a total without a problem.

I have all the base totals adding up to a Sub Total without a problem.

Heres where the fun starts...

I then have a shipping charge that I need added on.

$0.00 - $25.00 adds $7.00
$25.01 - $50.00 adds $8.50
$50.01 - $100.00 adds $12.00
$100.01 and over adds $15.00

Is there a way to program something like this in a calculation or anyway to make it work? I also want to have the shipping charge needs to be added displayed in a box I have laid out already.

Here is a link to the form if anyone doesn't understand.

http://www.blockparent.on.ca/documents/forms/ResourcesOrderForm_Fillable.pdf

Thank you in advance to anyone that can help me on this. I also apoligize my JavaScript programming is very weak.

My Product Information:
Acrobat Pro Extended 9.2, Windows
StevenD
Registered: Oct 6 2006
Posts: 368
I just found your post and I don't know if you have found a solution or not but you could use a bit of JavaScript in your Total Charge field that would get the value of the Sub Total field and determine in which range the value falls and add the shipping charges to the Total. So here is one way I tried out.

You would put this in a custom calculation script in your Total Charge field instead of using the calculation method that is being used now. Here is the script. Just remove the /* at the beginning of the code and the */ at the end. Those are comments and the script won't perform if they are there.

/*
var mySubTot = getField("Sub Total").value;

if(mySubTot != 0.00)
{

if(mySubTot >= 0.00 && mySubTot <= 25.00)
{
this.event.value = mySubTot + 7.00;
}

if(mySubTot >= 25.01 && mySubTot <= 50.00)
{
this.event.value = mySubTot + 8.50;
}

if(mySubTot >= 50.01 && mySubTot <= 100.00)
{
this.event.value = mySubTot + 12.00;
}

if(mySubTot > 100.01)
{
this.event.value = mySubTot + 15.00;
}
}
*/

Hope this give you some idea of an automatic way to get shipping costs add in instead of having the user choose something.

StevenD

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
I would not be using a drop down list for this field since you can automatically calculate the amount from the value of the 'Sub Total' field. I would replace the drop down box with a read only text field formatted for numbers and use a custom calculation script.

With careful ordering of you test you can simplify the calculation:
event.value = 0; // default valuevar mySubTot = this.getField("Sub Total").value; if(mySubTot > 100) {event.value = 15;} if(mySubTot <= 100.00) {event.value = 12;} if(mySubTot <= 50.00) {event.value = 8.5;} if(mySubTot <= 50.00) {event.value = 12;} if(mySubTot >= 0.00 & mySubTot <= 25.00) {event.value = 7.00;}

Or with the switch statement:
var mySubTot = this.getField("Sub Total").value; switch(true) { case (mySubTot <= 25):event.value = 7;break; case (mySubTot <= 50):event.value = 8.5;break; case (mySubTot <= 100):event.value = 12;break; case (mySubTot > 100):event.value = 7.00;break; default:event.value = 0;break;} // end switch

You also appear to have an issue with the order of the field calculations.

You can make all of your calculated fields read only and remove the 'required' option.

George Kaiser

ontarioblockparent
Registered: Feb 16 2010
Posts: 16
WOOOOHOOOOOO!!!!!!! IT WORKS!!!!!!!!!!

Thank you both very much for your help.