Highlighted

Using Month and Year to Auto Fill Week Days with and without Saturdays - that fall in the month

Community Beginner ,
Aug 10, 2020

Copy link to clipboard

Copied

Good Day, 

 

I am working on a pdf that has a month and year section at the top and autofills the weekdays, with and without Saturdays. 

I am sure there is an easier way to do it but I have been able to get it work but can't figure out how get it to leave the field blank if the Date Month does not match the Month field. 

 

In the Example for march, it lists all weekdays for march but continues to April. I would like it to only list the days in the specified month. 

 

Any help would be very much appreciated. 

MarkBB87_0-1597086810741.png

 

I have attached the pdf I have been working on. 

 

Thank you, 

TOPICS
Edit and convert PDFs, How to, PDF forms

Views

84

Likes

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

Using Month and Year to Auto Fill Week Days with and without Saturdays - that fall in the month

Community Beginner ,
Aug 10, 2020

Copy link to clipboard

Copied

Good Day, 

 

I am working on a pdf that has a month and year section at the top and autofills the weekdays, with and without Saturdays. 

I am sure there is an easier way to do it but I have been able to get it work but can't figure out how get it to leave the field blank if the Date Month does not match the Month field. 

 

In the Example for march, it lists all weekdays for march but continues to April. I would like it to only list the days in the specified month. 

 

Any help would be very much appreciated. 

MarkBB87_0-1597086810741.png

 

I have attached the pdf I have been working on. 

 

Thank you, 

TOPICS
Edit and convert PDFs, How to, PDF forms

Views

85

Likes

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
Aug 10, 2020 0
Most Valuable Participant ,
Aug 10, 2020

Copy link to clipboard

Copied

The code under your fields is not the same, so it's a bit difficult to help you with it, but you can use something like this (this is from D25):

 

 

 

var sDate1 = this.getField('D24').value;
var oDate1 = util.scand("ddd, mmm dd, yy", sDate1.toString());
var fDate1 = oDate1.valueOf();
var fMDay = 1000 * 60 * 60 * 24;
// add 7 days to date
var fDate7 = fDate1 + (1 * fMDay);
// convert millisecond for date + 7 days to date time object
var d = new Date(fDate7);

event.value = "";
if(d.getDay()==0){
	d.setDate(d.getDate()+1);
}else if(d.getDay()==6){
	d.setDate(d.getDate()+2);
} else d.setDate(d.getDate())
if (d.getMonth()==oDate1.getMonth())
	event.value = util.printd("ddd, mmm dd, yy", d);

 

 

 

I would highly recommend you use a doc-level function for this, instead of re-writing the code for each one of the fields. It will work much more consistently (for example, clear the Year field and see what happens) and be much easier to edit...

 

Edit: Code fixed

Likes

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
Reply
Loading...
Aug 10, 2020 0
Community Beginner ,
Aug 11, 2020

Copy link to clipboard

Copied

I tried it but it gives SyntaxError: syntax error 16: at Line 17. 

 

Thank you for your help. 

Likes

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
Reply
Loading...
Aug 11, 2020 0
Most Valuable Participant ,
Aug 11, 2020

Copy link to clipboard

Copied

Copy it again.

Likes

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
Reply
Loading...
Aug 11, 2020 0
Community Beginner ,
Sep 16, 2020

Copy link to clipboard

Copied

Thank you, it worked great. The only other issue I am running into is when selecting the months, if you select the current month it messes up towards the end.

 

I attached the pdf again. On September for example it reapeats to the 17 when the current month is September. It did it on August, until it was September. 

 

Thank you, any help is greatly appreciated. 

Likes

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
Reply
Loading...
Sep 16, 2020 0
Most Valuable Participant ,
Sep 16, 2020

Copy link to clipboard

Copied

Your codes are a complete mess, each field has a completely different script. You need to use the same script for all the fields (preferably in a function) with just a different number of days added to each one.

Also, there are errors in your code. For example, there's no such date format as "mmn dd, yy"...

Likes

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
Reply
Loading...
Sep 16, 2020 0
Community Beginner ,
Sep 16, 2020

Copy link to clipboard

Copied

What would you charge to redo the code? 

Likes

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
Reply
Loading...
Sep 16, 2020 0
try67 LATEST
Most Valuable Participant ,
Sep 16, 2020

Copy link to clipboard

Copied

You can contact me privately via [try6767 at gmail.com] to discuss it further.

Likes

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
Reply
Loading...
Sep 16, 2020 0