Get number of days in a month based on month and year fields
I have a column on my form that enumerates the days in a month. I want to setup a hidden field that calculates the total number of days in a month based on month and year field inputs. The number of days will determine what shows up on the column. For example, if I put 4 in the month field, and 2016 in the year field, I get 30 in the hidden field. So on the "Day" column, I will have numbers 1 to 30 listed. Or if I put 2 in the month field and 2016 in the year field, I get 29 in the hidden field. So the numbers 1 - 29 will be listed in the "Day" column.
Found this code from some javascript forum:
//Month is 1 based
function daysInMonth(month,year) {
return new Date(year, month, 0).getDate();
}
//July
daysInMonth(7,2009); //31
//February
daysInMonth(2,2009); //28
daysInMonth(2,2008); //29
I don't know how to convert this code to adobe JavaScript and don't really know how to use it. All I know how to do is to setup the field values for the month and year fields as variables. I am a novice programmer and would really appreciate all the help I can get. Thank you in advance!
