0

I want a jQuery 3 months calendar to be shown on the page. User will select some date and click on a button to view the schedules.

I tried with below jQuery code

<input type="text" id="dp-text-box" />

$("#dp-text-box").datepicker({               
            numberOfMonths: 3,               
            dateFormat:'yy/mm/dd'
        });

However it will show the textbox and user has to click to open datepicker.

But in my case i should show the datepicker default and allow the user to navigate.

Please find the attached image that i need.My Date Picker Requirement

2 Answers 2

3

From the manual,

Display the datepicker embedded in the page instead of in an overlay. Simply call .datepicker() on a div instead of an input

HTML

<div id="datepicker"></div>

jQuery

$( "#datepicker" ).datepicker({
    numberOfMonths: 3,
    onSelect : function( selDate, instance){
        alert(selDate);
    }
});

Note: onSelect bit not tested, but should work.

Sign up to request clarification or add additional context in comments.

3 Comments

This worked like charm! Thanks. But how we get the selected date without a textbox? I want the selected date to process.
You can still have the onSelect event on this datepicker. Let me know if you can take care of it, or need some pointers on how it is done
Sure i will be taking care of this with some hidden field and setting the value in onSelect event. If i am wrong you can correct me !
0

Use div instead of textbox

javascript

$(function() {
    $( "#datepicker" ).datepicker();
});

html

<div id="datepicker"></div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.