How to programmatically submit form

hi
i have a form. what i want to do is hide the form from the user, fill the form elements with javascript and submit the form. but neither ('form').submit() or (’#submit_button’).click() works. is there a correct way to do this ?