Add popup to custom HTML fields
BWPanda - October 26, 2009 - 02:51
| Project: | Date |
| Version: | 6.x-2.4 |
| Component: | Date Popup |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I've created my own, custom HTML form with date fields that I'd like to use date_popup. However, I can't seem to get it to work...
The links in the Date_Popup README.txt file tell me to create a function that runs datepicker() on any fields you tell it to, but the following code's not working for me:
$(document).ready(function() {
$('#depart').datepicker();
$('#arrive').datepicker();
});What am I doing wrong?

#1
I was having the same problem. You first have to load 3 files (at least) using drupal .JS:
(you have to write this inside PHP tags)
drupal_add_js('sites/all/modules/date/date_popup/lib/ui.datepicker.js');
drupal_add_js('sites/all/modules/date/date_popup/lib/jquery.timeentry.pack.js');
drupal_add_js('sites/all/modules/date/date_popup/date_popup.js');
Also at the end of your form you do what you were doing:
$(document).ready(function() {
$('#depart').datepicker();
$('#arrive').datepicker();
});
Probably it's not the best solution, but it works. If you find a better way to do this please post again here.
Hope that works for you, it worked for me :)
#2
Thanks BetoAveiga, that works perfectly!
For the record, I used the following code to set a custom format for the date:
$('#depart').datepicker({dateFormat: 'dd/mm/yy'});#3
Automatically closed -- issue fixed for 2 weeks with no activity.