EasyUI Forum
October 11, 2025, 03:46:57 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: Date Time Box Add Year Button  (Read 8984 times)
AJLX
Newbie
*
Posts: 17


View Profile
« on: March 02, 2017, 04:39:01 AM »

Hello Guys,

I want to add a button to the date box editor so that when I click on it, it selects the same date, but next year. So if today is
02/03/2017 when I click this button it returns 02/03/2018. It should be simple, but I'm totally new to Jquery. I come for a PHP background. I can understand you not wanting to give me the full answer, but could you help me with some advice on the steps I need to take.

Thanks,

Andy
Logged
jarry
Administrator
Hero Member
*****
Posts: 2300


View Profile Email
« Reply #1 on: March 02, 2017, 08:10:07 AM »

Please look at this code. It adds a new button 'NextYear' to the datebox.
Code:
$(function(){
$('#db').datebox({
buttons: (function(){
var buttons = $.extend([], $.fn.datebox.defaults.buttons);
buttons.splice(1, 0, {
text: 'NextYear',
handler: function(target){
var opts = $(target).datebox('options');
var c = $(target).datebox('calendar');
var date = c.calendar('options').current;
date.setFullYear(date.getFullYear()+1);
$(target).datebox('setValue',opts.formatter(date));
$(target).datebox('hidePanel');
}
});
return buttons;
})()
})
})
Logged
AJLX
Newbie
*
Posts: 17


View Profile
« Reply #2 on: March 05, 2017, 10:49:58 AM »

Thanks,

I've added that code into the body of the page, and it just adds a new date box. presumably I need to put it somewhere sensible!?

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!