jquery change event on date calculation -
i add x number of months dropdown (month_number) start date end date calculated , shown correctly:
$('#start_date').change(function(){ var months = +$('#month_number').val(); var end = new date($(this).val()); end.setmonth(end.getmonth() + months); $('#end_date').val( (end.getmonth() + 1) + '/' + end.getdate() + '/' + end.getfullyear()) ;
demo: https://jsfiddle.net/8epztlv2/3/
but want changing dropdown (month_number) end date not changing !
here's fiddle.
$('#start_date, #month_number').change(function() { var months = $('#month_number').val(); var end = new date($('#start_date').val()); end.setmonth(end.getmonth() + number(months)); $('#end_date').val((end.getmonth() + 1) + '/' + end.getdate() + '/' + end.getfullyear()); });
you have add changing event select element. value of end getting $('#start_date').val()
instead of $(this).val()
.
Comments
Post a Comment