I have a search form through which users can, well, perform searches. When the “advanced search” checkbox is checked, a new part of the form shows, allowing for full customisation of the search. For a multitude of reasons, I have decided to send the form using the “get” method, thus displaying all variables in the url.
Problem is, when submitting a non-advanced search, the variables from the advanced part are still sent using the get method, making for a lengthy URL when it is not needed, as the advanced variables aren’t used by the PHP that handles the search.
To hide the advanced form when the “advanced search” checkbox isn’t checked, I’ve put the advanced form in a div of its own and have JavaScript set its style.display to “none” when the checkbox isn’t checked, and have it reset to default when it is.
How would I best go about submitting only part of the form when “advanced search” isn’t checked? A form within a form, removing and re-writing the div’s content instead of simply hiding it, or what? Or is there an easy trick to this nobody’s told me about?
Thanks!
you should probably use the attribute
on the input fields when you do not want to submit them
you can find more information in this article
you will probably need to keep your “display:none” as the rendering of disabled elements depends on the browser.