I have a form with some fields that are in a hidden DIV (style=”display: none;”). The user can click a button that displays these additional fields if they wish.
Now if the user submits the form in its “compact” state, the form variables in the hidden div are also submitted and displayed in the address bar.
How can I change this behaviour so that only the visible form fields are submitted?
Use POST instead of GET.
Set the
disabledattribute to true when the fields are hidden and enable them again when the fields are shown.disabledwill prevent them from being submitted.