This is a migrated thread and some comments may be shown as answers.

Populate DatePicker with JavaScript issue

2 Answers 139 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 2
Brett asked on 03 May 2010, 09:46 PM
Here is my code...
  strDOB = strDOB & "/" & mid(USBHID.GetTrack(2), 30, 2) & "/" & mid(USBHID.GetTrack(2), 32, 2)  
document.getElementById ("ctl00_ContentPlaceHolder1_fvClients_DOBTextBox").value = strDOB 
It should populate my datepicker with the date of birth from my Javascript.

However this dosen't work using the control above, nothing is entered into the datepicker (and yes I have verified the variable holding the date is valid using an alert box) and looking at my rendered source code, I see that RadCalendar produces two more input controls:
ctl00_ContentPlaceHolder1_fvClients_DOBTextBox_dateInput_text
ctl00_ContentPlaceHolder1_fvClients_DOBTextBox_dateInput

If I change my JS code to populate these input boxes, I start to see results, however they still do not work.  If I use the input control which ends in "dateInput" and then click in the radDatePicker after it populates, the input control clears and the date is lost.

Then if I use the input control which ends in "dateInput_text" and then click in the radDatePicker after it populates, the input control changes to "0NaN/0NaN/0NaN" and the date reverts back default "minDate" of 1998/12/31

So my question is, using JS what input control should I be targeting and how do I get the date to "stick" even when someone clicks in the datePicker control field?

2 Answers, 1 is accepted

Sort by
0
Brett
Top achievements
Rank 2
answered on 06 May 2010, 09:41 PM
Anyone?
0
Dimo
Telerik team
answered on 07 May 2010, 11:16 AM
Hello Brett,

You should use the datepicker's API to set a value, not DOM operations. Here is the API:

http://www.telerik.com/help/aspnet-ajax/calendar_clientsideraddatepicker.html

set_selectedDate() is what you need. The method should be executed to the control's instance, not a DOM element.

http://www.telerik.com/help/aspnet-ajax/calendar_clientsidebasics.html

Greetings,
Dimo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Calendar
Asked by
Brett
Top achievements
Rank 2
Answers by
Brett
Top achievements
Rank 2
Dimo
Telerik team
Share this question
or