I have 2 date elements on a form. Each shows the time selector. In the javascript onChange event of the first date element I have a call to function start_date_change(this); This function calls an updEndDate function. Details in the following code segment:
As you can see in the updEndDate function I have temporarily hard coded a fix time to set the end_date element to. When the start date element changes all the functions are called correctly but the time portion of the element is not updated. Here is a screen grab of the result:
Code:
function updEndDate() {
var form = getForm();
var vStartDate = form.formElements.get("tqkjo_appointments___start_date").get("value");
if (vStartDate == "") {
/* we don't have a start date yet so wait a bit */
return;
}
var eEndDate = form.formElements.get("tqkjo_appointments___end_date");
var vDuration = form.formElements.get("tqkjo_appointments___duration").get("value");
// eEndDate.set(moment(vStartDate).add(vDuration, "minutes").format("YYYY-MM-DD HH.mm.ss"));
eEndDate.set("2017-12-12 12:12:12");
}
/* Process a change to the start date */
function start_date_change(el) {
/* We want to adjust the end date based on the duration */
var form = getForm();
var curDuration = form.formElements.get("tqkjo_appointments___duration").get("value");
if (curDuration == "") {
return;
}
updEndDate();
}
function getForm()
{
var form = Fabrik.getBlock("form_8");
if (form === false) {
form = Fabrik.getBlock("details_8");
}
return form;
}