title: Javascript: ncaught TypeError: Cannot read property 'split' of null
body: <p>I dont understand what is happening here? any suggestions? This is happening on this line :-</p>
  
  <pre><code>var explode = gregorianDate.split('-');
  </code></pre>
  
  <p>Here is full function.</p>
  
  <pre><code>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+'&amp;year='+year+'&amp;day='+day;
         ajax.callPage(url, showSubscribeResult, "GET");
      }           
  }
  </code></pre>