I have a page that loads dates into a hidden field.
I'm using Javascript to parse and hilight the dates. Using an onClick function works perfectly, but I need this to load when the document is ready. Every time I try this I get "Cannot call method 'selectDates' of null" - which implies that the calendar is not yet loaded. I tried using the onLoad and onInit events - same error.
Here's the code:
If I call this using jQuery, I still get the error - what the hell is going on?
Gimzani
I'm using Javascript to parse and hilight the dates. Using an onClick function works perfectly, but I need this to load when the document is ready. Every time I try this I get "Cannot call method 'selectDates' of null" - which implies that the calendar is not yet loaded. I tried using the onLoad and onInit events - same error.
Here's the code:
<script type="text/javascript"> //------------------------------------------------------------------------------- function renderDates() { //--------------------------------------- var calendar = $find("<%= cal_Calendar.ClientID %>"); var hf_Dates = document.getElementById("<%= hf_SelectedDates.ClientID %>"); //hidden field var DateStrings = hf_Dates.value.split('|'); //--------------------------------------- var Dates = new Array(DateStrings.length); for (var i = 0; i < DateStrings.length; i++) { var dt = convertToTriplet(DateStrings[i]); //see function below... Dates[i] = dt; } //--------------------------------------- calendar.selectDates(Dates); //ERROR OCCURRS HERE! } //------------------------------------------------------------------------------- function convertToTriplet(dateString) { var dp = dateString.split('/'); var array = new Array(dp[2], dp[0], dp[1]); return array; } //------------------------------------------------------------------------------- </script>If I call this using jQuery, I still get the error - what the hell is going on?
Gimzani