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.
I have attached the pdf I have been working on.
Thank you,
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
Copy link to clipboard
Copied
I tried it but it gives SyntaxError: syntax error 16: at Line 17.
Thank you for your help.
Copy link to clipboard
Copied
Copy it again.
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.
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"...
Copy link to clipboard
Copied
What would you charge to redo the code?
Copy link to clipboard
Copied
You can contact me privately via [try6767 at gmail.com] to discuss it further.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Without seeing the file and/or the code it's very difficult to say.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
kindly
can you write the code
Copy link to clipboard
Copied
Sure. Contact me privately for a quote.