Topic: set datepicker value from another datepicker

Aletiger premium asked 3 years ago


Hi, I have 2 datepicker in the same page, when i change the date in the first i need to change automatically the date in the second (to next day of the first). For example: in the first i choose today and click ok, in the second i need automatically set tomorrow. is possible to make this? there is a list of method to modify via script the value (set, get..)

Thanks in advance.



You can use dateChange.mdb.datepicker to add event listener to the first datepicker. When it triggers, it will initialize new datepicker with min date set.

Check this snippet: https://mdbootstrap.com/snippets/standard/grzegorz-bujanski/2869557#js-tab-view


Aletiger premium answered 3 years ago


Thanks for the feedback, it was much appreciated. I have another question, if i want to change the option MIN of second datepicker when i choose the date in the first, is it possible? Even better, I want to set the MIN with the date i've choosed in the first. Thanks in advance.


Małgorzata Olborska staff answered 3 years ago


You can use dateChange.mdb.datepicker event and add event listener to the first datepicker. Inside callback, set a new value to the second datepicker. It triggers the change in the second datepicker whenever you change the date in the first one.

Check example snippet: https://mdbootstrap.com/snippets/standard/molborska/2859352


Aletiger premium commented 3 years ago

Thanks for the feedback, it was much appreciated. I have another question, if i want to change the option MIN of second datepicker when i choose the date in the first, is it possible? Even better, I want to set the MIN with the date i've choosed in the first. Thanks in advance.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Premium
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: 3.0.0
  • Device: Notebook
  • Browser: Firefox and Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No