Auto form submit with javascript in Drupal

I'm sure some people know how to do this, but when i approached this task, i was confused. So:
1. Find a proper form_id of form you want to submit automatically with javascript. You can find it in html generated by Drupal
2. Use a hook_form_alter to add this elements to form. Without them, after javascript submit, Drupal FAPI do not know what to do with form.

  $form['op'] = array(
    '#type' => 'hidden',
    '#value' => t('Post comment') // The task was to autosubmit comment reply form
  );
  $form['form_id'] = array(
    '#type' => 'hidden',
    '#value' => 'comment_form' // comment_form for me and form_id you want to submit
  );

3. Then in the javascript when you call
document.getElementById('comment-form').submit();

you'll have drupal form submitted in a normal way it should.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.