Topic: Set Datetimepicker dynamically
analyticsteamperpetuum-com pro premium asked 3 years ago
Expected behavior
I would expect to be able to set the value from javascript, using something like follows:
let date = new Date('2022-07-10T13:24:00');
document.getElementById('myDateTime').value = date;
When I click to change the value, then the currently selected date/time should match this value.
Actual behavior
Although this displays something in the input box, when I click to change the value there is no currently selected date or time in the popup dialog.
Resources (screenshots, code snippets etc.)
I have also tried setting the value using the locale-specific string format used, to no avail. Any help greatly received!
Dawid Wajszczuk staff answered 3 years ago
Hi,
You need to dispose datetimepicker and then reinitialize it with new date and new time. Here is the snippet https://mdbootstrap.com/snippets/standard/d-wajszczuk/3682055#js-tab-view.
Keep coding,
Dawid
ppt pro premium answered 3 years ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 3.10.2
- Device: Desktop
- Browser: Edge
- OS: Win10
- Provided sample code: No
- Provided link: No