I dont understand what is happening here? any suggestions? This is happening on this line :-
var explode = gregorianDate.split('-');
Here is full function.
function updateCalendarDay(){
if (document.getElementById('gregorianDateOutput') != null) {
var gregorianDate = document.getElementById('gregorianDateOutput').value;
}else{
var gregorianDate = null;
}
if(gregorianDate != ""){
var explode = gregorianDate.split('-');
var year = explode[0];
var month = explode[1];
var day = explode[2];
document.getElementById('month').value = month;
document.getElementById('year').value = year;
var ajax = new GLM.AJAX();
var url='calendarAjax.php?month='+month+'&year='+year+'&day='+day;
ajax.callPage(url, showSubscribeResult, "GET");
}
}
As @Jasper suggest you can assign empty String if not found:
var gregorianDate = "";
instead of
var gregorianDate = null;
EDIT:
Also you can check just by value:
if( gregorianDate )
And as Element value
property always return's String you will get this only if value is present
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With