mdupras Posted June 12, 2009 Report Share Posted June 12, 2009 Hi all -- I'm building a real estate transaction database that uses a separate web form that passes parameter to a search and report form on the same page. The idea is that when the database is initially accessed it will display a map of the most recent real estate transactions in the database; the user can then use the form to generate a new search to filter and/or expand the results. Part of search is a date range, and I'm using JavaScript to calculate a default date range of the previous 20 days for that initial view. What I'm trying to do is insert those two dates into virtual fields on the web form. But it's not working -- the JavaScript to get the dates works fine, as I've done document.write to test it, but I can't get those values to insert into the fields. Here's my code: function dateRange() { var today = new Date(); var range = -20; var startDate = new Date(today.getFullYear(), today.getMonth(), today.getDate()-0+range); var thisMonth = today.getMonth() + 1; var startMonth = startDate.getMonth() + 1; var enterStartDate = startMonth + "/" + startDate.getDate() + "/" + startDate.getFullYear(); var enterEndDate = thisMonth + "/" + today.getDate() + "/" + today.getFullYear(); document.getElementById('caspioform').InsertRecordcbParamVirtual4.value = enterStartDate; document.getElementById('caspioform').InsertRecordcbParamVirtual5.value = enterEndDate; } onload=dateRange; Thanks for the help! -- Mike Quote Link to comment Share on other sites More sharing options...
bahar_vm Posted June 12, 2009 Report Share Posted June 12, 2009 Hi Mike, The last two lines are not correct, use the following instead: document.getElementById('caspioform').cbParamVirtual4.value = enterStartDate; document.getElementById('caspioform').cbParamVirtual5.value = enterEndDate; "InsertRecord" will only be used for regular fields not virtual fields. Best, Bahar M. Quote Link to comment Share on other sites More sharing options...
mdupras Posted June 15, 2009 Author Report Share Posted June 15, 2009 That did the trick -- thanks so much! -- Mike Quote Link to comment Share on other sites More sharing options...
Aether Posted July 10, 2019 Report Share Posted July 10, 2019 Hi @mdupras, You can now use "Calculated field/ values and Formula field" to calculate the date range. Check this documentation for the list of calculation or formula you can use inside Caspio:https://howto.caspio.com/function-reference/ https://howto.caspio.com/datapages/datapage-components/calculated-values/ https://howto.caspio.com/tables-and-views/data-types/formula-fields/ https://howto.caspio.com/datapages/reports/advanced-reporting/calculations-in-forms-and-reports/ 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.