• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Automatic calendar in text boxes when month is selected

Contributor ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

Hello everyone,

 

how can I create a calendar with TextBoxes so that the underlying text field always adds a day. Since I am unsure how and whether I can formulate it correctly, I have included the picture.

Would like to do the same with Adobe (TextBoxes instead of cells) as in Excel, is that possible? …if yes how?

Unbenannt3.jpg

 

Thanks everyone in advance

 

Nikolaos.

TOPICS
Create PDFs , How to , JavaScript

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

I don't understand why you changed my code. It would have worked fine. Here's the fixed version.

View solution in original post

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

Yes. It's possible using a script.

So the user will enter the first date, right? What format will they be using?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

The user should only enter the month.

The format is German, otherwise the way it looks.

 

Thx 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

So they enter a number, between 1 and 12, then?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

If possible with a drop down field where the user can select the month would be best.

If not possible, I'll take what is possible 🙂

 

Thx

Nikolaos.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

Will it always be the current year?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

Yes, as long as I can change it with the script 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

I would be happy to receive a suggested solution.

 

... and thanks again in advance 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 09, 2021 Nov 09, 2021

Copy link to clipboard

Copied

OK, create a Drop-down field with all the month names (and a default value, something like "Select Month"), and 31 text fields called "Day.1", "Day.2", etc.

Then use this code as the custom Validation script of the drop-down (you'll need to adjust the first two arrays to have the correct day and month names to match the ones you're using):

 

 

var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

for (var i=1; i<=31; i++) this.getField("Day."+i).value = "";
if (event.value!=event.target.defaultValue) {
	var monthIndex = months.indexOf(event.value);
	var d = util.scand("m/d/yyyy", (monthIndex+1) + "/1/" + new Date().getFullYear());
	while (d.getMonth()==monthIndex) {
		this.getField("Day."+d.getDate()).value = d.getDate() + " - " + days[d.getDay()];
		d.setDate(d.getDate()+1);
	}
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 09, 2021 Nov 09, 2021

Copy link to clipboard

Copied

Thanks very much :-),

will try it out and give feedback.

 

Nikolaos.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

sorry for the late reply but my obligations have gotten out of hand.

I installed it as it is in your instructions.

Enter the months in the element list in the drop-down menu and enter the script

in the user-defined area (in the validation).

I labeled the days as described (Day.1, Say.2, etc.).

But after selecting the month in the preview, nothing appears.

I also changed the format to German, but didn't help either.

 

I'm doing something wrong, it would be nice if you could give me a tip.

 

*Adobe Acrobat Pro Dc - Version: 2015.006.30527

 

Thx in Advance,

 

Nikolaos.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

Are there any errors in the JS Console after you make the selection (Ctrl+J)?

Can you share the file?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

sry my mistake installed it again on a blank pdf page and it works ... great! 🙂 

The only thing I can't do is instead of example: to display the day, from this (1 - Freitag), in (01. Fr.).

 

I tried to change it with the underlying script (everything in blue), but without success.

How could I change it like that?

 

var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

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

 

for (var i=1; i<=31; i++) this.getField("Day."+i).value = "";

if (event.value!=event.target.defaultValue) {

                var monthIndex = months.indexOf(event.value);

                var d = util.scand("dd . ddd.", (monthIndex+1) + "/1/" + new Date().getFullYear());

                while (d.getMonth()==monthIndex) {

                               this.getField("Day."+d.getDate()).value = d.getDate() + " . " + days[d.getDay()];

                               d.setDate(d.getDate()+1);

                }

}

 

Thank you for your patience and time 🙂

 

Nikolaos.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

additionally here the file ... January works ... but february and the rest ... I probably have a mistake somewhere.

 

thx 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

I don't understand why you changed my code. It would have worked fine. Here's the fixed version.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

A late and small last additional question has arisen 🙂

I tried it myself but without success.

How can I put the existing code that you sent me into a fixed year.

 

Example that it is for 2022 or 2023, depending on what you want?

 

Thanks 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

LATEST

Change:

new Date().getFullYear()

To:

"2022"

or

"2023"

etc.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

Now it has sparked! 🙂

sorry for the annoyance, everything worked wonderfully

... only the one with 01 instead of 1 (day: 01,02,03,04,05,06,07,08,09,10, etc.).

Your template script is SUPER! 🙂 🙂

Attached are the changes (java script with changes) that I have made so far, it is suitable for German speakers.

 

I would be happy if you could give me a suggestion for a solution to insert the zero before the individual numbers. 

 

var days = ["So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."];
var months = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"];

for (var i=1; i<=31; i++) this.getField("Day."+i).value = "";
if (event.value!=event.target.defaultValue) {
	var monthIndex = months.indexOf(event.value);
	var d = util.scand("m/d/yyyy", (monthIndex+1) + "/1/" + new Date().getFullYear());
	while (d.getMonth()==monthIndex) {
		this.getField("Day."+d.getDate()).value = d.getDate() + " - " + days[d.getDay()];
		d.setDate(d.getDate()+1);
	}
}

 

 

Thank you for everything, especially for the patience and time you have invested in me.

 

Nikolaos.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

Change this line:

 

this.getField("Day."+d.getDate()).value = d.getDate() + " - " + days[d.getDay()];

 

To this:

 

var dateString = d.getDate()<10 ? "0"+d.getDate() : d.getDate();
this.getField("Day."+d.getDate()).value = dateString + " - " + days[d.getDay()];

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

A dream! thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines