title: retrieve the wrong data in the condition
body: <p>I have a function for date, where the condition is if the user chooses today's date, RM 10.00 will be charged, if user chooses tomorrow's date, the charge is 5.00, else it will 0.00. for each condition, i have to create a session so that it can be passed to other module. However, when user chooses the date and click next, the data for the session also return the last value from the last condition, where the value is 0.00. below is the code:</p>
  
  <pre><code>window.onload = function(){
  var d = new Date();
  d.setDate(new Date().getDate());
  
  var time = d.toTimeString().substr(0, d.toTimeString().lastIndexOf(" "));
  
  if(d.toTimeString() &gt; "17.00")
  {   
      $(document).ready(function() {
          $('#datepicker-example2').Zebra_DatePicker({
              direction:1,
              onSelect: function(view, elements) {
  
                  var month = d.getMonth()+1;
                  var day = d.getDate();
                  var next_day = 1;
                  var tomoro = new Date();
                  var res = tomoro.setTime(tomoro.getTime() + (next_day * 24 * 60 * 60 * 1000));
                  tomoro = new Date(res);
                  var tom_month = tomoro.getMonth()+1;
                  var tom_day = tomoro.getDate();
  
                  var currDate = d.getFullYear() + '-' +
                      ((''+month).length&lt;2 ? '0' : '') + month + '-' +
                      ((''+day).length&lt;2 ? '0' : '') + day;
  
                  var tomDate = tomoro.getFullYear() + '-' +
                      ((''+tom_month).length&lt;2 ? '0' : '') + tom_month + '-' +
                      ((''+tom_day).length&lt;2 ? '0' : '') + tom_day;   
  
                  if($('#datepicker-example2').val() == currDate)
                  {
                      $('#charge').val('RM10.00');
                      setSession('10.00');
  
                  }else
                  if($('#datepicker-example2').val() == tomDate)
                  {
                      $('#charge').val('RM5.00');
  
                      setSession('5.00');
                  }else
                  {
                      $('#charge').val('RM0.00');
                      setSession('0.00');
                  }
              }
          });
      }); 
  }
  }
  
  function setSession(str)
  {
  $.ajax({url: "set_session.php", type: "post", data: {"ses": str}})
  }
  </code></pre>
  
  <p>page for set_session.php<br></p>
  
  <pre><code>&lt;?php session_start();
  $ses = $_POST['ses'];
  $_SESSION['charge'] = $ses; ?&gt;
  </code></pre>
  
  <p>the main file is saved in .tpl</p>
  
  <p>*<strong>Update:</strong>
  now i can get the value,but seems like there is a problem with the event. for ex:
  at first i choose today's date , so the charge suppose to 10rm. but it shows 0. then i go back to the previous page, choose tomorrow's date, the charge suppose to be 5rm, but it shows 10rm, which is the prev record session. and if i go back,n choose another date, it will show 5rm, n etc. </p>
  
  <p>Am i using the wrong event? or what happen to that? how i'm supposed to solve it?</p>