I am a complete novice. I have read numerous articles to try to get the answer to my query and feel more confused than when I started... I feel overwhelmed by Java Script!
I am trying to create a calculation in an Acrobat 9.0 form which works out a payment date based on an inception date, the number of agreed payments and the overall time period. i.e.:
DueDate1 = "if Payments is more than 0, then add Calc1 [which is number of days between installments] to Inception else leave this field blank".
Once I sort this, I'll need to move onto:
DueDate2 = if Payments is more than 1, then add Calc1 to DueDate1 else leave this field blank".
Etc. up to DueDate11
Based on one article I saw, I put in the following in my DueDate1 field using the Custom Calculation Script:
var nPayments = this.getField("payments").value;
if( nPayments > 0)
event.value = nCalc1 + nInception;
else
event.value = 0;
Absolutely nothing happens. No error messages. Nothing.
Additional info on text fields involved:
Payments = the number of installments that will be paid and is formatted as a number
Months = how long the Installment agreement will last
Calc1 = is the result of Payments / Months * 30 to give me how much time to add to each installment date and is formatted as a number
Inception = the start date of the Installment plan, the date the deposit is paid and is formatted as a date.
DueDate1 = where I want to calculation to happen and is formatted as a date
Because there is a date involved and I'm adding a number to it to get a new date, do I need to change the date to milliseconds? If so, how?
Help!
Have you read the series Working With Date and Time in Acrobat JavaScript in the Learning Center? Those articles cover all the basics and if you are developing forms with date and time features you should definitely read them and try out the examples. There is a downloadable PDF with just what you want to do- it is a matter of you spensding the time to implement this on your form.
Part 1 is here-
http://www.acrobatusers.com/tutorials/2006/date_time_part1
Hope this helps,
Dimitri
WindJack Solutions
www.pdfscirpting.com
www.windjack.com
Dimitri Munkirs
WindJack Solutions
pdfscripting.com