BehNaman Posted August 23, 2022 Report Share Posted August 23, 2022 Hi! In my table, I have a formula that gets the last day of the month, and I would like to make it the default value of my text field. Is there a way to do that? Quote Link to comment Share on other sites More sharing options...
futurist Posted August 23, 2022 Report Share Posted August 23, 2022 Hi @Gigigigi, You can do this using the following script: <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { var date = new Date(); var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0); function getFormattedDate(date) { var year = date.getFullYear(); var month = (1 + date.getMonth()).toString(); month = month.length > 1 ? month : '0' + month; var day = date.getDate().toString(); day = day.length > 1 ? day : '0' + day; return month + '/' + day + '/' + year; } var datesearch = document.querySelector("#Value3_1"); datesearch.value = getFormattedDate(lastDay); }); </script> Make sure to change the Value3_1 in document.querySelector("#Value3_1") with the id of the text field that you want to add the date to. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.