Search code examples
javascriptjqueryurlform-fields

Conditionally skip form fields from submission, Reduce URL clutter


I have multiple hidden form fields which store values about the the current view (e.g. if certain, normally hidden div's are visible etc.) to restore the layout when the form posts back.

The problem is that I'm always submitting all these hidden fields, even if they are in default, generating lots of unnecessary URL clutter in the process (e.g. http://www.example.com/view?ab=&ac=&ad= and so on).

I'd rather submit only the fields which are actually influencing the view (meaning, don't have a specified default value) so that the URL clutter is at a minimum.

I tried manually deleting/inserting input's but its a nightmare. Is there a better way to do this?


Solution

  • Try disabling them-
    "Controls that are disabled cannot be successful." -- http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2