Hello @chrisgnw
There are different solutions available but depend on the project’s requirements.
Our plugin cannot generate fields at runtime by default. So, every field should be inserted in the form at development time.
Furthermore, you say the user can select periods. So, for every period you should insert a pair of date-time fields for the beginning and ending date/times. Assuming these fields are fieldname1 and fieldname2 and you want to know the days between them, the equation associated with the calculated field would be: ABS(fieldname1-fieldname2)
Now, suppose you want the user can enter a maximum of three intervals, but you don’t want the three intervals to be visible at once. A possible solution would be:
1. Insert a Div field for every interval, with the corresponding pairs of date fields within them. I’ll assume for this explanation that the names of div fields are: fieldname3 and fieldname4
2. Insert an “HTML Content” field in the form with the following piece of code:
<script>
var pair = '';
fbuilderjQuery(document).one('showHideDepEvent', function(){
IGNOREFIELD('fieldname2');
IGNOREFIELD('fieldname3');
});
function showPair()
{
if(pair == 'fieldname3') return;
else if(pair == '') pair = 'fieldname2';
else if(pair == 'fieldname2') pair = 'fieldname3';
ACTIVATEFIELD(pair);
}
function hidePair()
{
if(pair == '') return;
IGNOREFIELD(pair);
if(pair == 'fieldname3') pair = 'fieldname2';
else if(pair == 'fieldname2') pair = '';
}
</script>
Finally, insert a pair of button fields in the form to display and hide the pairs of date fields with the onclick events:
showPair();
and
hidePair();
respectively.
Best regards.
Thank you so much for such detailed reply.