2
 <form ... method="get">
 <checkbox name="category[]" value="1">
 <checkbox name="category[]" value="2">
 <checkbox name="category[]" value="3">
 ...

I want the final get query to look like the following, if all items are checked: ?category=1,2,3

If only 1 and 3 are checked: ?category=1,3

What's the best way to achieve this?

1 Answer 1

1

You could use Javascript to manipulate a hidden field:

<input type="hidden" name="category" value="" />

When either checkbox is changed, update the value (i.e. "1,3" or "1,2,3") as needed.

Sign up to request clarification or add additional context in comments.

1 Comment

No problem! I couldn't think of a better non-JS-dependent approach, but maybe somebody else will chime in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.