(function(){ function runBlock() { setTimeout(function(){ var wert = document.getElementById('form_token2167321648').value; document.getElementById('form_token').value = wert; }, 3000); } document.addEventListener('DOMContentLoaded', function () { runBlock(); }); $(document).on('click', '#submitbutton', function() { runBlock(); }); })();