title: Dynamic Date Select (Php/JS)
body: <p>I'm having problems trying to access a function inside a JavaScript script, so I can create a dynamic set of possible dates based on what month is selected.  It doesn't even seem to access the JavaScript function 'populate()' at all. The alert doesn't respond. I should probably mention this entire code is called from 'include_once();' in another file. I tried to follow the example from: <a href="http://www.youtube.com/watch?feature=player_embedded&amp;v=UliJeDbc4cw" rel="nofollow">http://www.youtube.com/watch?feature=player_embedded&amp;v=UliJeDbc4cw</a> </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function populate(month,day){
      alert('Javascript Reached');
      var month = document.getElementById('month');
      var day = document.getElementById('day');
  
      day.innerHTML="";
  
      if (month.value == "Apr" ||
          month.value == "Sep" || 
          month.value == "Jun" ||
          month.value == "Nov" ||
          ){
          var limit = 30;
          }
      else if(month.value =="feb"){
          var limit = 28;
      }
  
      else{
          var limit = 31;
      }
  
      while(var temp &lt; limit){
          var newOption = document.createElement("option");
          newOption.value = temp;
          newOption.innerHTML = temp;
          day.options.add(newOption);
          temp++;
      }
  
      return true;
  }
  &lt;/script&gt;
  &lt;?php
  adminYearOption();
  adminMonthOption();
  adminDayOption();
  
  function adminYearOption(){
      echo "&lt;select name='year'&gt;&lt;option value=''&gt;&lt;/option&gt;";
      while($datecount &lt; 50){
          $currValue = (1980+$datecount);
          echo "&lt;option value='".$currValue."'&gt;".$currValue."&lt;/option&gt;";
          $datecount++;
      }
      echo "&lt;/select&gt;";
  }
  
  function adminMonthOption(){
      ?&gt; &lt;select id='month' name='month' onchange="return populate(this.id,'day')"&gt;&lt;option value=''&gt;&lt;/option&gt;&lt;?php
      $time = strtotime("2013-01-01");
      while($datecount &lt; 12){
          $currValue = date('M',$time);
          echo "&lt;option value='".$currValue."'&gt;".$currValue."&lt;/option&gt;";
          $time = strtotime("+1 month", $time);
          $datecount++;
      }
      echo "&lt;/select&gt;";
  }
  
  function adminDayOption(){
      echo "&lt;select id='day' name='day'&gt;&lt;/select&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>'</p>
  
  <p>Also for any other reader that wants to create dynamic dates, here is an alternative:
  <a href="http://blog.elanman.com/2009/09/create-dynamic-date-selects/" rel="nofollow">http://blog.elanman.com/2009/09/create-dynamic-date-selects/</a> but it has a static amount of days for every month.</p>
  
  <p>I'm just curious as to why mine didn't work, I cant figure it out.</p>
  
  <p>Thanks.</p>