Misc. FORM Submission FAQs

Submission without using a submit button?

The question is often asked, whether a form can be submitted without using a submit button. (Here, the term "submit button" is understood in the generic sense, to cover INPUT TYPE=SUBMIT, INPUT TYPE=IMAGE and BUTTON TYPE=SUBMIT: in the terminology of HTML4.0 these are known collectively as "submit controls").

Within the scope of HTML alone, there is one case where that is possible, and that is the submission of a pre-determined form by means of METHOD=GET, by preparing the appropriate URL to represent the form submission, and using it as a normal anchor link, A HREF="...". This item seems to cause a lot of confusion, and is therefore discussed in detail, separately.

Beyond that, you'd need client-side scripting: some examples are mentioned below; but since, in a WWW context, there is no guarantee that client-side scripting will be enabled, it would, as always, be advisable to avoid making web pages entirely reliant on scripting if you can. (Nothing against client-side scripting as an optional enhancement: that's different.)

Submission by POST without a submit button?

No: within HTML the only way to initiate a POST is to submit a form. Form submission could be initiated via client-side scripting, subject to the usual caveat that there is no guarantee that it will be enabled, so it's advisable to design the page so that it's usable even when client-side scripting is disabled.

Form submission when a page is loaded?

Another popular question is how a form submission can be triggered when an ordinary page is loaded. Quite why this is so popular isn't entirely clear, but we'll skip that part of the issue in the present discussion.

There are several ways in which one could attempt to achieve this, again based on a coded URL of the type discussed later.

The only way that can be guaranteed to work in all situations is to have the page itself generated as a result of the form submission, and to access the page by means of such a coded URL. However, that is usually not what is wanted: the questioner wants a simple URL, without any evidence of a form submission showing in the browser's URL display.

One group of methods is based on calling up other kinds of object from the HTML page. The HTML constructs that do this (some standard, some vendor extensions) are IMG, EMBED, OBJECT, IFRAME etc. Of course, the form submission script at the server will need to return a result that consists of the expected kind of object, as well as doing whatever it does in response to the form submission. None of these methods can be guaranteed to work, as some browsers do not implement one or other of the above tags, and some browsers can have image loading turned off as an option.

Another group of methods relies on client-side scripting, such as Javascript, to activate a form submission (or to access a link to a coded URL as noted above and discussed in the separate article) when the page is loaded. In this case, the form submission script at the server could usefully return HTTP status 204 to tell the browser to stay on the same page. Quite apart from browser unreliability (the Javascript FAQs have a tip for dealing with onLoad events that don't work reliably), there is no guarantee that users will have Javascript enabled, or even implemented, in their browsers, so it would be unwise to make a page critically dependent on such a facility.

Further Resources

There's another look at form submission issues in detailed discussions and tutorials by J.Korpela, always a reliable contributor.


|Up|Next | |RagBag|About the author|