Reputation: 657
Is it possible to create an html checkbox form that will output to a url format such as:
?cat=cars+tree
Currently given this:
<form name="input" action="/" method="post" >
<br />Select Categories: <br />
<input type="checkbox" name = "cat" value="cars" /> Cars <br />
<input type="checkbox" name = "cat" value="tree" /> Tree <br />
<input type="checkbox" name = "cat" value="drinks" /> Drinks <br />
<input type="checkbox" name = "cat" value="food" /> Food <br /> <br />
<input type="submit" value="Submit" />
It would create this, if cars and tree are selected:
?cat=cars&cat=tree
Upvotes: 2
Views: 2601
Reputation: 29493
No, I am afraid with pure HTML this is not possible, since in the W3C Recommendation for the HTML 4.01 Specification the form URL encoding is specified as follows:
application/x-www-form-urlencoded
This is the default content type. Forms submitted with this content type must be encoded as follows:
Control names and values are escaped. Space characters are replaced by `+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').
The control names/values are listed in the order they appear in the document. The name is separated from the value by `=' and name/value pairs are separated from each other by `&'.
Upvotes: 4