eiwai
March 21, 2016, 3:53am
#1
Hi,
I am trying to set the new date inside form. When I try to use setDate function, it did return value as new date but the UI still remain as old date. Below is the code that I tried. I also tried SetFormatedDate function. Still the same. Anyway to change the date to new date?
I am using pro version of dhtmlx. I am not sure if you need demo for this. But I tried sending email to support@dhtmlx.com for another topic, but they said they never received it.I am not sure what went wrong. Is there any other way to send demo?
<script src="Scripts/jquery-2.1.4.js"></script>
<style type="text/css">
.dhxform_obj_dhx_skyblue {
font-family: Arial !important;
}
.LabelHeader {
color: black !important;
font-family: arial !important;
}
.dhxform_obj_dhx_skyblue .dhxform_textarea {
/*border: 0px !important;*/
/*background-color: transparent !important;*/
/*font-size: 8pt !important;*/
font-family: arial !important;
}
.dhxform_obj_dhx_skyblue div.dhxform_txt_label2 {
color: black;
font-weight: normal;
/*font-size: 8pt !important;*/
font-family: arial !important;
}
.dhxform_obj_dhx_skyblue fieldset.dhxform_fs legend.fs_legend {
color: black !important;
font-weight: normal !important;
/*font-size: 8pt !important;*/
font-family: arial !important;
}
.dhxform_obj_dhx_skyblue fieldset.dhxform_fs {
border: 1px solid gray !important;
}
</style>
<script type="text/javascript">
var myForm, formData;
$(document).ready(function () {
doOnLoad();
});
var selecteddate1;
var selecteddate2;
var box = null;
function doOnLoad() {
var dt = new Date();
var dtStr = ("0" + dt.getDate()).slice(-2) + "/" + ("0" + (dt.getMonth() + 1)).slice(-2) + "/" + dt.getFullYear();
selecteddate1 = dtStr;
selecteddate2 = dtStr;
formData = [
{ type: "newcolumn", offset: 5 },
{
type: "calendar", dateFormat: "%d/%m/%Y", name: "Trans_Date1", label: "Date", labelWidth: "30", inputWidth: "60", value: selecteddate1, hidden: false
},
{
type: "calendar", dateFormat: "%d/%m/%Y", name: "Trans_Date2", label: "Date", labelWidth: "30", inputWidth: "60", value: selecteddate2, hidden: false
},
{ type: "button", name: "SetDate", value: "SetDate", offsetLeft: 0, offsetTop: 0, width: "70" }
];
form_container = new dhtmlXForm("form_container", formData);
form_container.setFontSize("8pt");
form_container.attachEvent("onButtonClick", function (id) {
if (id == "SetDate") {
debugger;
var a = "29/02/2016";
var correctDate = a.split(/\//).reverse().join('/');
var newSelectedDate = new Date(correctDate);
form_container.getCalendar("Trans_Date2").setDate(newSelectedDate);
}
})
}
</script>
Thank you.
Andrei
March 22, 2016, 11:24am
#2
Hi
Could you please provide us complete demo including all correspondnig js/css files?
Please also add information regarding current and expected behaviour.
Here is a small guide how to make a complete demo:
docs.dhtmlx.com/tutorials__auxil … pport.html
If you don’t want to share your demo here for any reasons - you can send it to support@dhtmlx.com , if so - please include link to this forum topic.
If you’re using PRO Edition please send your demo to support@dhtmlx.com