Skip to main content
Participant
January 10, 2025
Question

Form field Month customizations

  • January 10, 2025
  • 2 replies
  • 553 views

I have a rental agreement that I would like to update with some conditional form fields. I allow my tenants to choose either a 3-month or 6-month autorenewing contract, but also like to spell out for them the months which the contract will renew on. To make it super easy for me, and to not make me look/feel like an idiot counting on my fingers when a tenant sits down with me to sign, I would love to have either a dropdown with the month of the initial signing, that pre-populates the next signing months based on their term.

 

For example, if they sign a 3-month renewal lease in January, then the next form will auto populate April, the following July,  the final in September.

 

Or, if they choose a 3-month in March it would be >> June >> September >> December.

 

Does that make sense?

2 replies

Thom Parker
Community Expert
Community Expert
January 10, 2025

To get the new month names you'll need a mapping object. Then the current month can be identified relative to the following months. 

 

Here's a simple script that is placed in the "Validation" script for the initial signing month dropdown. 

The script assumes the names of the next signing months are "NextSign1", "NextSign2", "NextSign3"

 

 

var aMonthNames =["January","February", "March", "April", "May", "June", "July", "August", "September", "October","November","December"];

var nMnthNum = aMonthNames.indexOf(event.value);

for(i=1;i<=3;i++)
   this.getField("NextSign" + i).value = aMonthNames[(nMnthNum + i*3)%12];

 

 

This script can be modified to include the signing period and number of periods. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
January 10, 2025

Oh wow! I didn't expect such a quick response!

Here is a screenshot of how the document is currently set up. Right now I have them just as text boxes.

 

So, I would need one form for the 6-month and another for the 3-month

Thom Parker
Community Expert
Community Expert
January 11, 2025

You can have one form  that includes all options. 

However, in order to script the actions you would like, the form fields have to be named. It is the names that the script uses to manipulate the field data. 

You can read more about form scripting here:

https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
January 10, 2025

Do you have a separate field for the duration of the contract, or do you have one drop-down that corresponds with 3 months, and another with 6?