views:

113

answers:

2

I need to fire the jquery datepicker from a link click. Right now if i click on the textbox the datepicker opens which is great but i have a button next to the textbox that someone can click and it needs to open the datepicker next to it. Also I would like a label instead of a textbox, is that possible. The code is below:

$(document).ready(function(){
   $("#mydate").datepicker({ maxDate: '+1y', minDate: new Date() });

});

   <li class="quick_date"><%= text_field_tag "mydate", Date.now.strftime('%m/%d/%Y'), :size => 10 %> <a id="quick_search" href="#">(Change Me)</a></li>
+1  A: 

To make the #quick_search link open the datepicker you can do this:

var mydate = $("#mydate").datepicker({ maxDate: '+1y', minDate: new Date() });
$("#quick_search").click(function(){
    mydate.datepicker("show");
});
PetersenDidIt
thanks for that what about turning it from a textbox to a label is that possible
Matt
Why would you want to change the date of a `<label>`? If you really want to do that you can use the `onSelect` event.
PetersenDidIt
A: 

try

.datepicker({ showOn: 'button'})
katrin