views:

146

answers:

1

I have two related questions...

  1. How do I update an HTML element (let's say a p tag) with the correct date when I click on a day in the jQuery UI datepicker plug in?

  2. If I have another way to selecte a date aside from the datepicker, how do I then update the datepicker's selected date (it's adds a class of "ui-state-active" to the date)?

A: 
  1. Use the altField:

    $("#datepicker").datepicker({altField: '#alternate'});

  2. Use the setDate method:

    .datepicker( "setDate" , date )

More informations here.

aeby
for the first answer...It's works with an <input> field but not with a <p> tag.For example..Works:<input type="text" id="alternate" size="30"/>Doesn't Work:<p id="alternate">Date here</p>How can i get it to work with the <p> tag?
sevens
a possible workaround: attach an onSelect handler, format the date and write it via the html() function to your element. Or you could style your input field with css that it looks like you want to. ;-)
aeby