I haven’t used this tool before, but it does what you want. You could just look at it’s source to get some ideas:
For your situation, you would add this code:
<script type="text/javascript" src="https://stackoverflow.com/questions/1959398/jquery.autotab.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#first').autotab({ target: '#second', format: 'numeric' });
$('#second').autotab({ target: '#third', format: 'numeric', previous: '#first' });
$('#third').autotab({ previous: '#second', format: 'numeric' });
});
</script>