Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By adijadhav
#789949
Hiii
in a form i am taking number of months then he enters first date. then next date must be automatically calculated.
like if 11 month and first date is 2017-24-03 then next date must be 2018-23-02. it must check leap year also
User avatar
By amosbatto
#789953
There are examples in the Datetime wiki page if you want to do this with PHP. If you want to do this with JavaScript, it is a bit harder.

For example you have two datetime fields with the IDs "contractStart" and "contractEnd". Then you can use the following JavaScript code, which automatically inserts the date 11 months later in the contractEnd when the value of contractStart changes:
Code: Select all
$("#contractStart").setOnchange( function(newVal, oldVal) {
  if (newVal == '') {
    $("#contractEnd").setValue('');
  }
  else {
    var contractStart = moment(newVal);
    var contractEnd = moment(contractStart).add(11, 'M');
    var contractMonthEnd = moment(contractEnd).endOf('month');
    //check whether the end month has fewer days in it than the start month:
    if (contractEnd.format("YYYY-MM-DD") > contractMonthEnd.format("YYYY-MM-DD")) {
       contractEnd = contractMonthEnd;
    }

    $("#contractEnd").setValue(contractEnd.format("YYYY-MM-DD"));
  }
})
Here is a sample DynaForm with this example:
(3.7 KiB) Downloaded 317 times

Winzo is a popular and unique game on the mobile p[…]

Cannot create process using templets

Real details. The problem was solved by effect!

However, it is essential to use it responsibly and[…]

Web3 development encompasses creating decentralize[…]