monim67 / django-bootstrap-datepicker-plus

Bootstrap3/Bootstrap4/Bootstrap5 DatePickerInput, TimePickerInput, DateTimePickerInput, MonthPickerInput, YearPickerInput with date-range-picker functionality for django >= 2.0
https://pypi.python.org/pypi/django-bootstrap-datepicker-plus
MIT License
223 stars 61 forks source link

How to set picker value from custom javascript #95

Open nicholas-ewing opened 1 year ago

nicholas-ewing commented 1 year ago

I have a button which I want to do a few different things at the same time and I'm lost on how to set the picker's value to the current datetime from my JavaScript. I've tried setting the picker directly and I'm able to see the datetime in the field, but it doesn't carry over to the hidden input. I then tried setting the hidden input directly but it also did not carry over to be visible in the field. Is there a better way to do this than to individually set both?

Setting Picker Field: $('#completed-datetime')[0].value = dtFormat(new Date(), 'yyyy-mm-dd hh:mmi:ss');

Setting Hidden Input: $("[name='datetime_completed']")[0].value = dtFormat(new Date(), 'yyyy-mm-dd hh:mmi:ss');

Thanks in advance for any assistance.