Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display jquery datepicker on link click?

I need to show jQuery UI datepicker on link click, also when a date is picked change link text to this date, how can I do it?

like image 826
Burjua Avatar asked Feb 22 '11 18:02

Burjua


People also ask

How to show DatePicker using jQuery?

Syntax: $(". selector"). datepicker("show");

How do you show a date picker?

An optional initialEntryMode argument can be used to display the date picker in the DatePickerEntryMode. calendar (a calendar month grid) or DatePickerEntryMode. input (a text input field) mode. It defaults to DatePickerEntryMode.


2 Answers

jQuery UI date picker should do the job.

Check out the example using an icon to trigger the picker: http://jqueryui.com/demos/datepicker/#icon-trigger

You can also call the show() method to drop down the picker whenever you need to, e.g...

$('#mypicker').datepicker({
      //options
      minDate: '20.04.2012'
      //...
    });
$('#mylink').click(function(){
      $('#mypicker').datepicker('show');
    });

To change the link text after a date is selected, use something like this in initialization code:

$('#mypicker').datepicker({ onSelect:
    function(dateText, inst) {
        $('#mylink').text(dateText);
    }
});
like image 54
DigitalDan Avatar answered Sep 19 '22 20:09

DigitalDan


$("#dateField").datepicker({
 dateFormat:'dd/M/yy',
 minDate: 'now',
 changeMonth:true,
 changeYear:true,
 showOn: "focus",
 //buttonImage: "YourImage",
 buttonImageOnly: true, 
 yearRange: "-100:+0",  
}); 

$("dateField").datepicker( "option", "disabled", true );
like image 22
Girish Avatar answered Sep 21 '22 20:09

Girish