Latest Register Log In

+ Advanced Search

Searching by State

Searching by State
By
10/10/08 (Edited 11/03/14)

Here's a common scenario: you want to allow your visitors to search for listings within the states of their choice, multiple-choice. Here's an example search form you can use:

<form action="search.php?action=filter&filled=1&whichtype=links" method="post">
<p>Choose the states you want to search in:</p>
<table>
<tr>
<td valign="top">
<input type="hidden" name="statecondition" value="or" >
<input type="checkbox" name="statesearch[]" value="select all" onclick="checkuncheckstates()" > All States<br >
<input type="checkbox" name="statedirectoriessearch[]" value="Alabama" > Alabama<br ><input type="checkbox" name="statedirectoriessearch[]" value="Alaska" > Alaska<br ><input type="checkbox" name="statedirectoriessearch[]" value="American Samoa" > American Samoa<br ><input type="checkbox" name="statedirectoriessearch[]" value="Arizona" > Arizona<br ><input type="checkbox" name="statedirectoriessearch[]" value="Arkansas" > Arkansas<br ><input type="checkbox" name="statedirectoriessearch[]" value="California" > California<br ><input type="checkbox" name="statedirectoriessearch[]" value="Colorado" > Colorado<br ><input type="checkbox" name="statedirectoriessearch[]" value="Connecticut" > Connecticut<br ><input type="checkbox" name="statedirectoriessearch[]" value="Delaware" > Delaware<br ><input type="checkbox" name="statedirectoriessearch[]" value="District Of Columbia" > District Of Columbia<br ><input type="checkbox" name="statedirectoriessearch[]" value="Federated States Of Micronesia" > Federated States Of Micronesia<br ></td><td valign="top"><input type="checkbox" name="statedirectoriessearch[]" value="Florida" > Florida<br ><input type="checkbox" name="statedirectoriessearch[]" value="Georgia" > Georgia<br ><input type="checkbox" name="statedirectoriessearch[]" value="Guam" > Guam<br ><input type="checkbox" name="statedirectoriessearch[]" value="Hawaii" > Hawaii<br ><input type="checkbox" name="statedirectoriessearch[]" value="Idaho" > Idaho<br ><input type="checkbox" name="statedirectoriessearch[]" value="Illinois" > Illinois<br ><input type="checkbox" name="statedirectoriessearch[]" value="Indiana" > Indiana<br ><input type="checkbox" name="statedirectoriessearch[]" value="Iowa" > Iowa<br ><input type="checkbox" name="statedirectoriessearch[]" value="Kansas" > Kansas<br ><input type="checkbox" name="statedirectoriessearch[]" value="Kentucky" > Kentucky<br ></td><td valign="top"><input type="checkbox" name="statedirectoriessearch[]" value="Louisiana" > Louisiana<br ><input type="checkbox" name="statedirectoriessearch[]" value="Maine" > Maine<br ><input type="checkbox" name="statedirectoriessearch[]" value="Marshall Islands" > Marshall Islands<br ><input type="checkbox" name="statedirectoriessearch[]" value="Maryland" > Maryland<br ><input type="checkbox" name="statedirectoriessearch[]" value="Massachusetts" > Massachusetts<br ><input type="checkbox" name="statedirectoriessearch[]" value="Michigan" > Michigan<br ><input type="checkbox" name="statedirectoriessearch[]" value="Minnesota" > Minnesota<br ><input type="checkbox" name="statedirectoriessearch[]" value="Mississippi" > Mississippi<br ><input type="checkbox" name="statedirectoriessearch[]" value="Missouri" > Missouri<br ><input type="checkbox" name="statedirectoriessearch[]" value="Montana" > Montana<br ></td><td valign="top"><input type="checkbox" name="statedirectoriessearch[]" value="Nebraska" > Nebraska<br ><input type="checkbox" name="statedirectoriessearch[]" value="Nevada" > Nevada<br ><input type="checkbox" name="statedirectoriessearch[]" value="New Hampshire" > New Hampshire<br ><input type="checkbox" name="statedirectoriessearch[]" value="New Jersey" > New Jersey<br ><input type="checkbox" name="statedirectoriessearch[]" value="New Mexico" > New Mexico<br ><input type="checkbox" name="statedirectoriessearch[]" value="New York" > New York<br ><input type="checkbox" name="statedirectoriessearch[]" value="North Carolina" > North Carolina<br ><input type="checkbox" name="statedirectoriessearch[]" value="North Dakota" > North Dakota<br ><input type="checkbox" name="statedirectoriessearch[]" value="Northern Mariana Islands" > Northern Mariana Islands<br ><input type="checkbox" name="statedirectoriessearch[]" value="Ohio" > Ohio<br ></td><td valign="top"><input type="checkbox" name="statedirectoriessearch[]" value="Oklahoma" > Oklahoma<br ><input type="checkbox" name="statedirectoriessearch[]" value="Oregon" > Oregon<br ><input type="checkbox" name="statedirectoriessearch[]" value="Palau" > Palau<br ><input type="checkbox" name="statedirectoriessearch[]" value="Pennsylvania" > Pennsylvania<br ><input type="checkbox" name="statedirectoriessearch[]" value="Puerto Rico" > Puerto Rico<br ><input type="checkbox" name="statedirectoriessearch[]" value="Rhode Island" > Rhode Island<br ><input type="checkbox" name="statedirectoriessearch[]" value="South Carolina" > South Carolina<br ><input type="checkbox" name="statedirectoriessearch[]" value="South Dakota" > South Dakota<br ><input type="checkbox" name="statedirectoriessearch[]" value="Tennessee" > Tennessee<br ><input type="checkbox" name="statedirectoriessearch[]" value="Texas" > Texas<br ></td><td valign="top"><input type="checkbox" name="statedirectoriessearch[]" value="Utah" > Utah<br ><input type="checkbox" name="statedirectoriessearch[]" value="Vermont" > Vermont<br ><input type="checkbox" name="statedirectoriessearch[]" value="Virgin Islands" > Virgin Islands<br ><input type="checkbox" name="statedirectoriessearch[]" value="Virginia" > Virginia<br ><input type="checkbox" name="statedirectoriessearch[]" value="Washington" > Washington<br ><input type="checkbox" name="statedirectoriessearch[]" value="West Virginia" > West Virginia<br ><input type="checkbox" name="statedirectoriessearch[]" value="Wisconsin" > Wisconsin<br ><input type="checkbox" name="statedirectoriessearch[]" value="Wyoming" > Wyoming<br >
</td>
</tr>
</table>

<br >Search for listings where the name contains
<input type="hidden" name="titlecondition" value="like" >
<input type="text" size="{STANDARDSIZE}" name="titlesearch" >
<br ><br >
<br ><input type="submit" value="Run Search" class="button" >

</form>


In Admin Panel -> Themes -> Manage Templates -> Extra Javascript Inclusions, insert this:

<script type="text/javascript">
function checkuncheckstates()
{
var boxes = document.getElementsByName('statedirectoriessearch[]');
for (i=1; i < boxes.length; i++)
{
if (boxes[i].checked == true) boxes[i].checked = false;
else boxes[i].checked = true;
}
}
</script>

This will display all the states (or provinces, depending on default country), 10 per column, with checkboxes and select all option.





Description Allowing visitors to search listings in their preferred states.
Rating
Views 546 views. Averaging 0 views per day.
Similar Listings