Jump to content

Using Java to Insert into Virtual Field on Web Form

Recommended Posts

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;

Thanks for the help!

-- Mike

Link to comment
Share on other sites

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.


Bahar M.

Link to comment
Share on other sites

  • 10 years later...

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:




Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...