Is there a well-supported, common behavior that I can expect if I do something like this in HTML:
<form method="get" action="/somePage.html?param1=foo¶m2=foo"> <input name="param2"></input> <input name="param3"></input> </form>
Seems like this sort of thing is inherently ridiculous, but I've seen it used here and there and I was wondering what on Earth the expected behavior should be. Are browsers smart enough to tack on "¶m2=whatever¶m3=whatever" to the action, or do they just throw in a second question mark? Or what? Are there cases where this is actually the right way to do things?
The action attribute defines the action to be performed when the form is submitted. Usually, the form data is sent to a file on the server when the user clicks on the submit button.
The HTML | action Attribute is used to specify where the formdata is to be sent to the server after submission of the form. It can be used in the <form> element. Attribute Values: URL: It is used to specify the URL of the document where the data to be sent after the submission of the form.
The HTML form action attribute defines what should happen to data when a form is submitted on a web page. The value of the action attribute should be the URL of the web resource that will process the contents of the form.
Yes, the form is required to have an action attribute in HTML4. If it's not set, the browser will likely use the same method as providing an empty string to it. You really should set action="" which is perfectly valid HTML4, follows standards, and achieves the same exact result.
If the method attribute is set to GET, the browser drops the querystring parameters from the action attribute before constructing the form argument values.
So in your example, the request to the server on submit will look like: /somePage.html?param2=value¶m3=value
So no, when the method is "GET", as in your example, there's no reason to do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With