I’m trying to figure out how to dynamically set two entry fields based on the current date. In this case, when the screen opens by default, the first entry should be 30 days prior to the current date and the second the actual current date.
The CurrentDate variable built in includes the day, but I only want the mm/dd/yyyy format. I was poking around and found a site that shows how to get the display right.
Edit: The code worked when I did a RunJS on the entry field, however there were a couple issues. The font style I defined did not hold and apply to the entry field. Nor could I edit the entry field to change the date. Worst case scenario is that I use text boxes with ChangeContent, but it would be pretty nifty if I could have a default and allow editing of the field.
This topic was modified 2 years, 10 months ago by Jason Dalrymple. Reason: experimented and was able to get code to work
var newDate1 = new Date();
var newDate2 = new Date();
newDate1.setDate(newDate1.getDate() - 30);
VarEntry_0001.set((newDate1.getMonth() + 1) + '/' + newDate1.getDate() + '/' + newDate1.getFullYear());
VarEntry_0002.set((newDate2.getMonth() + 1) + '/' + newDate2.getDate() + '/' + newDate2.getFullYear());
I didn’t think of running it at the page show – that works beautifully! Down the road as I make improvements over time, I’ll likely set this up so that it changes based on the selection of a drop down. Some of the choices will be tricky, since they’re sort of based on the current date (ie. last period, this period, etc.).