views:

62

answers:

2

i have the value polled from the db and if the user want to change it - i want the calendar to be set first to the date already in the field

im using asp and this picker http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/

A: 

If you are using my datepicker then all you should need to do is place the value from the database into the value of the field. How you do this will depend on what serverside language you use but an example in PHP:

<input type="text" id="my_date" value="<?php echo $date_from_db; ?>" class="datepicker" />

Presuming that $date_from_db is set in PHP to the date from the database as a string and is in the same format as you are using for the date picker.

vitch
i have update my question
Y.G.J
I can't remember much ASP classic but the equivalent of the above PHP would be something like: `<input type="text" id="my_date" value="<% Response.Write(date_from_db); %>" class="datepicker" />`To convert the date from the database to a string you will probably want to use the overloaded ToString which accepts a format parameter: http://msdn.microsoft.com/en-us/library/aa326721%28v=VS.71%29.aspx
vitch
i'm not talking about getting the date from the db - i know ho to do this. i'm talking about something else: when i have a date in the field, and the user click on the calendar icon, i want the calendar to be set to the date in the field
Y.G.J
Simply placing the date into the value of the input field will set the calendar to the relevant date. e.g. http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerPreFill.html
vitch
A: 

Found the solution: $('.date-pick').dpSetSelected('day/month/year');

Y.G.J
That isn't the optimal solution to the question as you asked it. My solution of placing the date in the input field is better because it won't then break your site when a user without JS visits. It is also cleaner because you are not writing out JS code from your serverside script. See the last example I linked to...
vitch
as i already said... in my date field of my form i already have the value set but the calendar is not changing... that is why i wanted it to be updated like this
Y.G.J
i will ask you to remove the voting because what you said is already there and the code is not retreiving the date from the field value... so using that dpSetSelected is the solution as it is on the author website
Y.G.J