Skip to content
Advertisement

How can I retrieve the selected date value from datepicker jQuery UI in order to trigger something

As the title mentions, I want to update my page with data in accordance with selected date in jQuery UI datepicker. So i need to retrieve the current date value if no date is selected or retrieve the selected date data and crush the current date value, so I can dynamically show things on the page regarding the selected date.

Here is my code for the datepicker so far :

JavaScript

So I need to be able to get selectedDate in date_choisie (maybe I should return selectedDate)

After this I will pass date_choisie to my PHP file by using ajax :

JavaScript

The URL will call the following php function :

JavaScript

Here are the functions used in getUserPlanning

JavaScript
JavaScript

By using getUserPlanning i can retrieve the selected date which is registered in data.datecourante

Advertisement

Answer

You can wrap your ajax call in a function and then call that function each time you select a new date.

To show the current OR selected date on screen you can use .text function display the date. As soon as the date page is loaded the ajax will be called and the current date data will fetch from PHP.

Lastly, once you do the ajax call you can show the PHP ajax data accordingly in your success function.

Edit: You can pass your selecteddate to this function as well => showplannings(data.datecourante, data.message, selectedDate); add a third argument in this function and receive this third argument in your showplannings function and do whatever is necessary.

Live Demo:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement