I have a form that I am updating the labels based on a date entered at the beginning of the form.
When the form is submitted, the date labels display correctly.
It is only when the user either downloads the form after submission or the form is saved to Laserfiche that the date labels display 2 months and 21 days off.
For instance, the date labels when the form is submitted is "09/09 Saturday". When the form is downloaded, the date label displays "11/30 Wednesday". The day of the week is incorrect as well. It should read "11/30 Thursday".
When I hard-code the parse_date (EX: parse_date = new Date (2017,8,9), the form will display in forms correctly and also download correctly displaying the correct lables.
Please see javascript below:
function datelabels(){ //Initialize Variables var str_date, parse_date; var arr_date = new Array (), arr_labels = new Array (); //Assign str_date str_date = $('.payperiod div[type="text"]').text(); if(str_date === ''){ str_date = $('.payperiod input').val(); } //BEGIN PROCESS - If Empty if(str_date !== ''){ //Get Year, Month, and Day arr_date = str_date.split('/'); //Build Labels List for All Tables for(var i = 13; i > -1; i--){ parse_date = new Date(parseInt(arr_date[2]), parseInt(arr_date[0]) - 1, parseInt(arr_date[1])); parse_date.setDate(parse_date.getDate() - i); str_date = addZero(parse_date.getMonth(), 'm') + '/' + addZero(parse_date.getDate(),'d') + ' ' + getDayString(parse_date.getDay()); //str_date = addZero(parse_date.getMonth(), 'm') + '/' + addZero(parse_date.getDate(), 'd') + ' ' + getDayString(parse_date.getDay()); arr_labels.push(str_date); } //END OF FOR LOOP i = 0;//Counter For Retrieve Dates From Array //IF COLUMN NAMES CHANGE, UPDATE THIS CODE!!!! $('.wlabels tr th label').each(function(){ if($(this).html() !== 'Payroll Use'){ if($(this).html() !== 'Total'){ $(this).html(arr_labels[i]); i++; } else { i = 0; } } }); } //END OF PROCESS }//END OF datelabels FUNCTION function addZero(num, type){ if(type === 'm'){ num = num + 1; } if(num < 10){ num = '0' + num; } return num; } //END OF addZero FUNCTION function getDayString(num){ var day; //Create a local variable to hold the string switch(num) { case 0: day="Sun"; break; case 1: day="Mon"; break; case 2: day="Tues"; break; case 3: day="Wed"; break; case 4: day="Thurs"; break; case 5: day="Fri"; break; case 6: day="Sat"; break; default: day="Invalid day"; } return day; } //END OF getDayString FUNCTION