Fran
Fran

Reputation: 17

Integrating jQuery DatePicker Calendar into Page

I am trying to integrate the jQuery datepicker calendar into my page. I don't want the user to have to click on the date field for the calendar to appear, I want them to be able to see the calendar as soon as the page loads. Is this doable, and if so, how?

I have been looking on StackOverflow for help but I'm not sure whether what I'm searching for is the correct way of describing it.

Thanks very much.

Upvotes: 0

Views: 66

Answers (2)

Daniel
Daniel

Reputation: 3514

As described in the documentation at jqueryui.com, you might simply call the .datepicker() method on a div instead of an input field to display the datepicker inline.

The only problem arousing of this usecase is the fasct, that you won't get the date directly inserted in an input field. You can retrieve the value by calling $("#yourDatepickerDiv").datepicker( 'getDate' );

Upvotes: 1

Jacob
Jacob

Reputation: 920

I think I understand what you are asking. You basically would just have to give the input focus on page load. I made a small fiddle to show this. Essentially it would just be

$(document).ready(function() {
    $('.date').datepicker().focus();
});

Upvotes: 1

Related Questions