< Back to Searching

Searching with Checkboxes

Sometimes you want to let people search by checking boxes (for example, checking the options they want with a product). This is possible with WSN.

Open your advanced search template (Admin Panel -> Themes -> Manage Templates -> "Advanced Search") or whichever template you're constructing a search form in. For a checkbox search for a multiple checkbox (or multiple selector) field, place this in the search form HTML:
<input type="hidden" name="multicheckcondition" value="or" >
multicheck: <input type="checkbox" name="multichecksearch[]" value="one" > one <input type="checkbox" name="multichecksearch[]" value="two" > two <input type="checkbox" name="multichecksearch[]" value="three" > three

Replace 'multicheck' with the name of your field and the numbers one through three with the possible values of your field. You can extend this to any number of options.

Please note that with the "or" value on mutlicheckcondition the search will return a topic if any of the searcher's checked boxes are checked on the topic. If you want to only match in the event that all of the searcher's checked boxes are also checked on the topic, change it to an "and" search: <input type="hidden" name="multicheckcondition" value="and" >

For a checkbox search for a single checkbox field (just on or off), use this HTML:
<input type="hidden" name="singlecheckcondition" value="=" >
<input type="checkbox" name="singlechecksearch" value="singlecheck" > singlecheck

Replace 'singlecheck' with the name of your field.