You're using the ID 'tMonth'
<input id='tMonth' value='<?php echo $tMonth;?>' name='tmes' type='text'>
but you're trying to get it as tmes
var tMonth=document.getElementById('tmes');
change the above line to
var tMonth=document.getElementById('tMonth');