0

I have this simple if/else but I cannot figure out why the else code will not execute. I am sure it is something simple but I do not see it and firebug does not have any alerts or errors.

HTML:

<input type="hidden" value="12" id="lastm">
<input type="hidden" value="2014" id="lasty">
<input type="hidden" value="1" id="thism">
<input type="hidden" value="2015" id="thisy">
<input type="hidden" value="12" id="ForMonth" name="ForMonth">
<input type="hidden" value="2014" id="ForYear" name="ForYear">
<input type="radio" checked="checked" value="0" id="last" name="last"> December 2014
<input type="radio" value="1" id="last" name="last"> January 2015

Javascript:

var last_month = 12;
var this_month = 1;
var last_year = 2014;
var this_year = 2015;

$('#last').change(function() {
  if($('#last').val() == 0) {
    //$('#ForMonth').val($('#lastm').val());
    $('#ForMonth').val(last_month);

    //$('#ForYear').val($('#lasty').val());
    $('#ForYear').val(last_year);
  }
  else {
    alert('here');
    //$('#ForMonth').val($('#thism').val());
    $('#ForMonth').val(this_month);

    //$('#ForYear').val($('#thisy').val());
    $('#ForYear').val(this_year);
  };
});
Jonas
  • 121,568
  • 97
  • 310
  • 388
Eman
  • 83
  • 6

0 Answers0