If I have an html document whose rough structure is
document.getElementById('username').value = 'foo'; document.getElementById('login_form').submit();