Variable keeps old value
<p>Whenever i click the '#print' button for the second time, the value from the first click prints out before the real value.</p>

<p>For example: 
I click button for the first time. The alert box prints out the correct value ('test1'). </p>

<p>I click button for the second time. The alert box prints out first value ('test1'), then i press OK, and right after that, the alert box prints out the second value ('test2').</p>

<p>Any ideas what i am doing wrong?</p>

<pre><code>$(".ipdate").focus(function() {

    /*$('.dateBox').hide();*/

    var tit = $(this).attr('id');
    /*var full = '#'+tit+'B';*/

    $('#dateBox').show();

    $('#print').on('click', function(){

       var bottle = $('.sday').val()+' '+$('.smon').val()+' '+$('.syear').val();
       $('#'+tit).val(bottle);
       alert(tit);

    });

    $('#close').on('click',function() {

         $('#dateBox').hide(); 

    });    
});
</code></pre>
