EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: thecyberzone on March 11, 2019, 03:51:06 AM



Title: [SOLVED] Adding days to datebox
Post by: thecyberzone on March 11, 2019, 03:51:06 AM
I have a easyui-datebox, say $('stdate') and another easyui-textbox $('days') contains number of days. After selecting any date from  $('stdate') I want to add  $('days') number of days and display the result into another easyui-datebox, say $('enddate').

Please help me.


Title: Re: Adding days to datebox
Post by: thecyberzone on March 11, 2019, 09:22:00 AM
This is my code :
Code:
	$('#stdate').datebox({
onSelect: function(d){
var g = $('#prog').combogrid('grid');
var r = g.datagrid('getSelected');

    var dt = new Date(d);
alert(dt);
    dt.setDate(dt.getDate() + r.DURATION);
alert(dt);    
    var dd = dt.getDate();
    var mm = dt.getMonth() + 1;
    var y = dt.getFullYear();

    var newDate = mm + '/' + dd + '/' + y;
    $('#enddate').datebox('setValue',newDate);
}
});

Each time I put 03/20/2019 in #stdate and 3 as days/duration, result in #enddate always shows 09/19/2019, and this is wrong answer. I could not understand why this is happening. Please help.


Title: Re: Adding days to datebox
Post by: thecyberzone on March 11, 2019, 09:35:23 AM
I have solved it, actually this line
dt.setDate(dt.getDate() + r.DURATION);
should be writen as
dt.setDate(parseInt(dt.getDate()) + parseInt(r.DURATION));