javascript - datepicker dynamic date button -


I am trying to create a custom dynamic date extra button in jquery datepicker. But does it not work ... error in my code? ($ {"Datepicker") datepicker ({dateFormat: "yy-mm-dd", changeMonth: true, change year: true, year category: "2014: 2034 ", ShowButtonPanel: Show first: function (input) {setTimeout (function () {var button page = $ (input) .tatpicker (" widget ") .Find (" .ui-datepicker-buttonpane "); var BTN = $ ('& lt; button class = "ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" type = "button" & gt; CSA & lt; / button & gt; '); Btn.unbind ("click") .bind ("click on", function () {//$.datepicker._clearDate (input); // alert (' custom text '); $ (input). Date picker ("hide"); var date = new date (); Date.setMonth (date.getMonth () + 6); $ (input) .val (date.getFullYear) + '-' date.getMonth () + '-' + 'date'getDate ());}); btn AppendTo (buttonPane);}, 1);}}); });

The target is to add a button today + 6 months

Remember one:

  $ (input) .val (date.getFullYear) + '-' date.getMonth () + '-' + Date .getDate ());  

To do this:

  $ (input) .val (date.getFullYear) + '-' + date.getMonth () + '- '+ Date.getDate ()); Do not forget that Javascript moth 0 is based, so if you want to add 6 months to today's date, then you have to add 7 to the current month, which means:    Date .setMonth (date.getMonth () + 6);  

Use:

  date.setMonth (date.getMonth () + 7);  

See examples


Comments