Xavier Posted June 17, 2019 Report Share Posted June 17, 2019 I've been trying to add a month to a date for the use of recurring payments. The code I have to put in the HTML block I have placed below. And thats a code i got from someone else on this website but it doesn't not work. Please help. [@field:New_Date*] <SCRIPT LANGUAGE="JavaScript"> function setDate() { var New_Date = "first"; var Current_Date_1 = "second"; New_Date = "InsertRecord" + New_Date; Current_Date_1 = "InsertRecord" + Current_Date_1; var New_Date = document.getElementById(New_Date ).value; var New_Date = new Date(Date.parse(New_Date)); var result_Date = new Date (first_Date.setMonth(first_Date.getMonth()+1)); var d_month = result_Date.getMonth() + 1; if (d_month<10) {d_month = "0" + d_month;} var d_day = result_Date.getDate(); if (d_day<10) {d_day = "0" + d_day;} var d_year = result_Date.getFullYear(); var str_date = d_month + "/" + d_day + "/" + d_year; document.getElementById(Current_Date_1[@field:Current_Date_1*] ).value = str_date; } document.getElementById("caspioform").onsubmit=setDate; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 18, 2019 Report Share Posted June 18, 2019 If it is on a submission page you do not have to use JS you can select Calculated Value as a form element for Current_Date field and use this formula: Dateadd(month, 1, GETDATE()) Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 18, 2019 Report Share Posted June 18, 2019 Here is the link to the article that shows how to add calculated values https://howto.caspio.com/datapages/datapage-components/calculated-values/ Quote Link to comment Share on other sites More sharing options...
Glitch Posted June 18, 2019 Report Share Posted June 18, 2019 You can just use a formula or even calculated field to achieve this. If I may ask, is there a need to use javascript? You can try this formula out: DateAdd(month, 1, [@field: YourDateField]) For future reference, you can check this link: https://howto.caspio.com/function-reference/ Hope this helps. Regards, Glitch 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.