Whenever i click the \'#print\' button for the second time, the value from the first click prints out before the real value.
For example: I click button for the first t
You are registering multiple events and that is why you see multiple actions! Did you see that? :) I had a similar situation and it took me a while to pick those out. You can unregister for the old event before issuing the new one.
$(".ipdate").focus(function() {
/*$('.dateBox').hide();*/
var tit = $(this).attr('id');
/*var full = '#'+tit+'B';*/
$('#dateBox').show();
$('#print').off('click');
$('#print').on('click', function(){
var bottle = $('.sday').val()+' '+$('.smon').val()+' '+$('.syear').val();
$('#'+tit).val(bottle);
alert(tit);
});
$('#close').off('click');
$('#close').on('click',function() {
$('#dateBox').hide();
});
});
This should fix your issue. Using off
will unregister the old events.