• Resolved Graicifyd

    (@graicifyd)


    If fieldname1 is a datetime field set at a default of 9:00am, I would like to set another datetime field – fieldname2 to be the previous time (the one in fieldname1) increased by 8 hours by default.

    Is there a way to use the getField(1).setVal operation? If not, how do you advise I do this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @graicifyd

    You can insert an “HTML Content” field in the form, and enter the following piece of code as its content:

    <script>
    fbuilderjQuery(document).one('formReady', function () {
        getField('fieldname2').setVal(GETDATETIMESTRING(DATETIMESUM(getField('fieldname1').val(true, true), 'mm/dd/yyyy hh:ii', 8, 'h'), 'mm/dd/yyyy hh:ii'));
    });
    </script>
    

    Note I assumed the date/time format of your fields is mm/dd/yyyy hh:ii

    Best regards.

    Thread Starter Graicifyd

    (@graicifyd)

    Excellent. Thanks a lot.

    Thread Starter Graicifyd

    (@graicifyd)

    For some reason, the fieldname2 does not change when I change the input in the first field.

    Plugin Author codepeople

    (@codepeople)

    Hello @graicifyd

    You requested to modify the default value and not future values. If you want to edit future values instead of using an “HTML Content” field you must use a calculated field with the equation:

    (function () {
        getField(fieldname2|n).setVal(GETDATETIMESTRING(DATETIMESUM(fieldname1, 'mm/dd/yyyy hh:ii', 8, 'h'), 'mm/dd/yyyy hh:ii'));
    
    })();

    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Increase Time in 8 hours Intervals’ is closed to new replies.