jQuery: The Write Less, Do More JavaScript Library

Datepicker - populate text field with date from database

View: New views
3 Messages — Rating Filter:   Alert me  

Datepicker - populate text field with date from database

by sunny beach :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am using the datepicker in a Rails application and it works fine to
create a record. Is there a way to have the datepicker text box
populate with the saved value pulled from the database?

I can easily retrieve and format the date correctly... just can't get
it in the box.


Thanks,
Sunny

--

You received this message because you are subscribed to the Google Groups "jQuery UI" group.
To post to this group, send email to jquery-ui@....
To unsubscribe from this group, send email to jquery-ui+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en.



Re: Datepicker - populate text field with date from database

by Fontzter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

var dateFromDbFormattedAccordingly;

$("#IdOfTheInputBoxThatHasTheDatepicker").val
(dateFromDbFormattedAccordingly);

That should be all there is to it.

Hth,

Dave

On Nov 8, 8:57 pm, Sunny Beach <sunnybeach1...@...> wrote:
> I am using the datepicker in a Rails application and it works fine to
> create a record. Is there a way to have the datepicker text box
> populate with the saved value pulled from the database?
>
> I can easily retrieve and format the date correctly... just can't get
> it in the box.
>
> Thanks,
> Sunny

--

You received this message because you are subscribed to the Google Groups "jQuery UI" group.
To post to this group, send email to jquery-ui@....
To unsubscribe from this group, send email to jquery-ui+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=.



Re: Re: Datepicker - populate text field with date from database

by sunny beach :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Many Thanks!

Got it working in about 5 minutes. For anyone else who runs across
this posting the code below will help.

To populate the purchase date from the database on the  "Edit Item" form:
$(function() {
        $("#datepicker").datepicker();
        var myDate="<%= @item.purchase_date.strftime("%m/%d/%y") %>";
        $("#datepicker").val(myDate);
});

To populate the current date on the "New Item" form:
$(function() {
        $("#datepicker").datepicker();
        var myDate="<%= Date.today.strftime("%m/%d/%y") %>";
        $("#datepicker").val(myDate);
});

On Tue, Nov 10, 2009 at 9:04 AM, Fontzter <dmfontz@...> wrote:

> var dateFromDbFormattedAccordingly;
>
> $("#IdOfTheInputBoxThatHasTheDatepicker").val
> (dateFromDbFormattedAccordingly);
>
> That should be all there is to it.
>
> Hth,
>
> Dave
>
> On Nov 8, 8:57 pm, Sunny Beach <sunnybeach1...@...> wrote:
>> I am using the datepicker in a Rails application and it works fine to
>> create a record. Is there a way to have the datepicker text box
>> populate with the saved value pulled from the database?
>>
>> I can easily retrieve and format the date correctly... just can't get
>> it in the box.
>>
>> Thanks,
>> Sunny
>
> --
>
> You received this message because you are subscribed to the Google Groups "jQuery UI" group.
> To post to this group, send email to jquery-ui@....
> To unsubscribe from this group, send email to jquery-ui+unsubscribe@....
> For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=.
>
>
>

--

You received this message because you are subscribed to the Google Groups "jQuery UI" group.
To post to this group, send email to jquery-ui@....
To unsubscribe from this group, send email to jquery-ui+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=.