i am using JavaScript to display an event calender. I want to show all the events dynamically. I have to fetch the values using ajax. The value is properly printed in the function but I want to use these value variables outside the function.
my function is:-
$(function () {
$("#calendar").datepicker({
dateFormat: 'mm/dd/yy',
beforeShowDay: checkBadDates
});
});
function calendarnew(apdate) {
dt = "";
var myData = apdate.split(",");
alert(myData);
dt = myData.join('","');
dt.replace(/\s+/g, '');
return dt;
}
var $myBadDates = new Array("10 May 2014", "21 May 2014", "12 May 2014");
function checkBadDates(mydate) {
var $return = true;
var $returnclass = "available";
$checkdate = $.datepicker.formatDate('dd MM yy', mydate);
for (var i = 0; i < $myBadDates.length; i++) {
if ($myBadDates[i] == $checkdate) {
$return = false;
$returnclass = "unavailable";
}
}
return [$return, $returnclass];
}
$(document).ready(function () {
calendarnew();
});
</script>
in this function how i use " dt " variable outside the function in the " $myBadDates ". please, suggest me.