Wednesday, 11 September 2013

passing two values for same checkbox field in get form

passing two values for same checkbox field in get form

I have a form with a method="get," and right now it looks like this:
<form>
<input type="submit" id="searchsubmit" value="Sort Projects"
class="project-sort" />
<input type="checkbox" name="type" class="type-checkbox"
value="type1">
<label for="type1">Type 1</label>
<input type="checkbox" name="type" class="type-checkbox"
value="type2">
<label for="type1">Type 2</label>
<input type="checkbox" name="type" class="type-checkbox"
value="type3">
<label for="type1">Type 3</label>
</form>
Yet, when I select two of them, the url it sends me to looks like this
/?type=type1&type=type2.
I've already tried adding [ ] to the input name, and when that happens,
the url appears like:
/?type%5B%5D=type1&type%5B%5D=type2
any idea what I'm doing wrong here?

No comments:

Post a Comment