HTML form: Is it possible to submit GET / POST parameters using only HTML or CSS?

I volunteer on a website that tries to completely free all JavaScript pages for free before adding any JavaScript for improvement, and I was asked to investigate whether a specific script can be processed exclusively through HTML / CSS,

We have a form that is filled in to help us filter out the list of tickets that appear on the screen after the page is refreshed using the GET action, which in itself works great, but the problem with the current implementation is that the URL cannot be translated into permalink. However, the request to keep constant communication as minimal as possible is to send only GET parameters for fields that are filled with something (therefore, suppressing GET parameters for fields that are empty) instead of having another GET parameter for each form a box on the page.

I thought of several ways that could be done, including JavaScript (for example: create fields with identifiers, but not names, and a hidden w / name field that JS uses to capture data from fields), but also one that will be a POST action redirected back to GET using a readable string that can be constantly used. The lead developer, however, would prefer not to go through the POST / redirect method, if at all possible.

Having said that, I try to cover all my databases and ask experts about this before I strongly insist on the POST / redirect solution: is there a way to use only HTML and CSS to directly suppress GET form parameters for fields that are empty, without using post / redirect?

+5
source share
3 answers

No, suppressing fields submitted in an HTML form using the "GET" method is not possible without using JavaScript or instead of submitting a form using the POST method and using a server-side function to minimize the form.

The fields presented are determined by the HTML specification , and only HTML and CSS cannot change this behavior and at the same time have browser compatibility. standards.

+1
source

No, you cannot programmatically suppress default browser behavior without using some kind of scripting language for clients, such as JavaScript.

As a side note, you say "JavaScript for enhancements," but JavaScript is not used for improvements these days. And no one in the real world would remain a decent interface without using JavaScript. I would suggest you just use JavaScript.

0
source

I do not think that you can avoid Javascript here to pre-process before submitting, in order to eliminate immutable / empty form fields.

0
source

Source: https://habr.com/ru/post/1240020/


All Articles