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

Autocalculate Month

paulaeddy
Registered: May 14 2010
Posts: 22
Answered

I have a form that I only need the name of the month to automatically populate based on an initial month entered by the user. For example, if the user enters "June", the next 11 fields would auto populate with the other months in order.

I can't seem to figure out how to calculate this? Thanks for your help!

My Product Information:
Acrobat Standard 9.3, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Have you tired using an array of the month's names. The following code will display the next 11 months, but not knowing your field names will make providing specific code more difficult.
// name of 12 monthsvar aMonths = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") // name of 12 months doubledvar aMonths24 = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); // name of month to start withvar sInput = "June"; // find index of imported monthfor(i = 0; i < aMonths.length; i++) {if(sInput == aMonths[i]){break;} // end input = month} // end index loop if(i < aMonths.length) {// process the next 11 elementsfor(j = i; j < (i + 11); j++) {app.alert( (j - i) + " month: " + aMonths24[j] );} // end for 11 months} else {app.alert('Invalid Month');}

George Kaiser

paulaeddy
Registered: May 14 2010
Posts: 22
The field names are: Month 1, Month 2, Month 3, etc through Month 12. Could I use code for each field? Example: Month 2 = (Month 1 + 1) of the array, Month 3 = (Month 2 + 1) of the array, etc? Thanks!
jimhealy
Team
Registered: Jan 2 2006
Posts: 146
var sInputMonth = getField("Month 1").value;var aMonths = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");var iStartMonth = aMonths.indexOf(sInputMonth);if(iStartMonth < 0) {app.alert("Error! Invalid Month.");}else {var y = 2;var x = iStartMonth + 1;while(x != iStartMonth) {if(x > 11)x = 0;else {getField("Month " + y.toString()).value = aMonths[x];y++;x++;}}}

Jim Healy
FormRouter, Inc.
Check out our FREE Advanced Acroform Toolset:
http://www.formrouter.com/tools

Jim Healy, Founder & CEO FormRouter Inc.
Chapter Leader AUG RTP NC
http://www.formrouter.com

paulaeddy
Registered: May 14 2010
Posts: 22
Perfect! Thanks soo much!