document.form.submit is not a function

Sometimes we may require our form to submit automatically when the browser loads. We can simply create a simple JavaScript function and call it at the event 'onload' when our page loads.
For this, we make the function call on the 'onload' attribute of the body tag of our HTML as below.

The Javascript Function:

Function Call during page 'onload':

However, this function call doesn't always work as expected. Sometimes we may encounter an error in our JavaScript error console that reads "document.formname.submit is not a function". This can occur when our form already contains a submit button named 'submit' and our function call is also calling the form's submit() method. Hence, there is a conflict in JavaScript as the submit method is bound to the 'submit' button.

Try renaming your submit button to anything other than 'submit' like name='Query' or something else and the function call will work.

Alternative approach that may even work:
Try calling the submit method on the function call by referencing the form with form's Id instead of its name as below.

The Javascript Function: