Skip to main content
ytk1978
Known Participant
December 13, 2019
Answered

Calendar drop down in a form only able to select mondays

  • December 13, 2019
  • 1 reply
  • 4717 views

Hello... brand new to Adobe acrobat pro DC.  Trying to create new pdf form using abobe acrobat pro dc and have few questions for many smart people.

 

Can you create drop down menu in pdf form with only bi weekly monday?  For example you can only select monday like

Mon, Dec 2, 2019 

Mon, Dec 16, 2019

Mon, Dec 30, 2019

Mon, Jan 13, 2020

.... and continues to be able tto pick Mondays?

 

In addition if this is possible, how do you code the another date field to auto fill calculated date value from the selected date?

6 days, 13days and  18days?

 

For example if user picks

Mon, Dec 16, 2019 from the drop menu, date I would need a date field auto filled by

Sun Dec 22, 2019, (6days)

Sun Dec 29, 2019, (13days)

Fri Jan 3, 2020. (18days)

 

Another date example:

Pick monday that is

Mon Dec 30, 2019

And auto filled date should be

Sun, Jan 5, 2020

Sun, Jan 12, 2020

Fri, Jan 17, 2020

 

Hope my posted question is understandable and thank you so much for your help.  Hope this is possible and once again. Thank you!

 

Please let me know if the question require clarification.  Thank you!

 

[Moving from generic Start/Help forum to the specific Program forum... Mod]
[To find a forum for your program please start at https://community.adobe.com/]

This topic has been closed for replies.
Correct answer bebarth
Thank you so much!

Time is no problem at all.

While I am at it, is there way to calculate time?

Time field 1 has 9:00 am
Time field 2 has 5:00 pm
And hr field 3 will do the calculation and give me 8 hours?

Thank you!

Hi,

That should definitely be another post, no?

Here is the adaptation of a script I found a long time ago, but I don't remember where:

function Time2Num(sFormat, sTime) {
if(sTime=="") return "";
var oTime=util.scand("mm/dd/yyyy "+sFormat, "01/01/1970 "+sTime);
var fTZOffset=oTime.getTimezoneOffset()*1000*60;
var fTime=oTime.valueOf()-fTZOffset;
return Math.round(fTime/1000);
}
event.value="";
var sStart=this.getField("startTime").value;
var sEnd=this.getField("endTime").value;
if(sStart != "" && sEnd != "") {
var fStart=Time2Num("hh:mm", sStart);
var fEnd=Time2Num("hh:mm", sEnd);
var fDiff=fEnd-fStart;
if (fDiff<0) fDiff=(24*3600)+(fEnd-fStart);
fDiff=Math.round(fDiff/60);
fHours=Math.floor(fDiff/60);
fMins=((fDiff/60)-fHours)*60;
sMins=util.printf("%,302.0f", fMins);
event.value=fHours+":"+sMins;
}

This script must be in calcul of the target field with the format HH:MM

Both startTime and endTime fields are with the format h:MM tt

You will find an example file at:

https://we.tl/t-HFp1uDauYx

@+

1 reply

ls_rbls
Community Expert
Community Expert
December 13, 2019

Hi,

 

I don't think is possible or even convenient  to add a dropdown menu that will provide an infinite list all Monday bi weekly dates.

 

You need a date picker instead with a validation script that will alert the user and prevent from selecting a date that doesn't falls on Monday.

 

This may be an advanced javascripting  task even if you're not entirely new to scripting, specifically using javascripts on date calculations.

 

Once you get the first date picker issue out of the way the second part is easier.

 

You can add a custom calculation script to the field that you need the dates to autopopulate, adding the desired number of days if certain conditions are met.

ytk1978
ytk1978Author
Known Participant
December 16, 2019

bebarth@free.fr, thanks for the great below script which you called it //The 10 next Mondays.

related to the script, can you enhance it by letting users put the date from the date give drop-down option of 10 previous and 10 next Mondays, instead of grabbing today's date?  I am not sure if that's a possibility but I wanted to check.

Here is an example of what I am inquiring /  checking.

 

user inputs date (anydate):  12/3/2019

from the inputted date by the user list the weekly Mondays... 5 previous Monday and 5 next Monday.

11/4

11/11

11/18

11/25

12/2

12/9

12/16

12/23

12/30

 

also, can you just do bi-weekly Mondays?  thank you so much for your help. 

 

your previous script.

// The 10 next Mondays

var toDay=new Date();

var theTime=toDay.getTime();

if (toDay.getDay()>=1) {

                var difference=7-toDay.getDay()+1;

} else {

                var difference=1;

}

this.getField("nextMondays").clearItems();

for (var i=9; i>=0; i--) {

                var theMonday=toDay.setTime(theTime+(((i*7)+difference)*24*3600*1000));

                var d=new Date(theMonday);

                var leLundi="Mon, "+util.printd("mmm dd, yyyy", d);

                this.getField("nextMondays").insertItemAt(leLundi,theMonday,0);

}

bebarth
Community Expert
Community Expert
December 16, 2019

did you change the date?  it happens after I change the date.  second and third time.  

 

 

 

it's still correct after changing the date!