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

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

Community Beginner ,
Aug 10, 2020 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

1.4K

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 ,
Aug 10, 2020 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

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 Beginner ,
Aug 11, 2020 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. 

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 ,
Aug 11, 2020 Aug 11, 2020

Copy link to clipboard

Copied

Copy it again.

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 Beginner ,
Sep 16, 2020 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. 

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 ,
Sep 16, 2020 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"...

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 Beginner ,
Sep 16, 2020 Sep 16, 2020

Copy link to clipboard

Copied

What would you charge to redo the code? 

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 ,
Sep 16, 2020 Sep 16, 2020

Copy link to clipboard

Copied

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

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
New Here ,
Jan 10, 2024 Jan 10, 2024

Copy link to clipboard

Copied

Screenshot (94).png

this is exactly what i need

but "why the autofill of days stop working on other text fields" after i changed the format of date on first text field to (dddd) only

need help plz

sorry for my english

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 ,
Jan 10, 2024 Jan 10, 2024

Copy link to clipboard

Copied

Without seeing the file and/or the code it's very difficult to say.

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
New Here ,
Jan 10, 2024 Jan 10, 2024

Copy link to clipboard

Copied

I appreciate your hard work

i hope get help in this and sorry for that

, i want  the text field fill (the name of the day only)  beacuse my job required that!.

and it's same file but i will attached (with saturday)

thank  you for your reply and your kind

 

 

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 ,
Jan 11, 2024 Jan 11, 2024

Copy link to clipboard

Copied

The issue is that in your code the subsequent fields after the first one are using the value of the previous field for the calculation (so D2S using D1S, D3S uses D2S, etc.), but that's not possible if that value is just a date. So you have to change their calculations to use the original selections, like D1S does. Then it would work.

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
New Here ,
Jan 11, 2024 Jan 11, 2024

Copy link to clipboard

Copied

kindly

can you write the code

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 ,
Jan 11, 2024 Jan 11, 2024

Copy link to clipboard

Copied

LATEST

Sure. Contact me privately for a quote.

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