EasyUI Forum
September 14, 2025, 12:50:17 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [SOLVED] Adding days to datebox  (Read 7261 times)
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« 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.
« Last Edit: March 11, 2019, 09:35:46 AM by thecyberzone » Logged
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« Reply #1 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.
Logged
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« Reply #2 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));
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!