Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shortcode Template for Area and Sub Area in Single Dropdown
<div class="search-item">
<label>Neighborhoods:</label>
<select id=hoodselect name='hood-select'>
<option value="">Any</option>
</select>
</div>
<div class="search-item">
<label>Min Beds:</label>[min_beds]
</div>
<div class="search-item">
<label>Min Baths:</label>[min_baths]
</div>
<div class="search-item">
<label>Min Price:</label>[min_price]
</div>
<div class="search-item">
<label>Max Price:</label>[max_price]
</div>
<div class="search-item">
<label>City:</label>[cities]
</div>
<div class="search-item ">
<input type="submit" name="submit" value="Search Now!">
</div>
<br><br>
<input type='hidden' id='location-neighborhood' name='location&#91;neighborhood]' ></input>
<input type='hidden' id='metadata-subdivision' name='metadata[sub_area]' ></input>
form.pls_search_form_listings .search-item { float: left; margin-bottom: 20px; width: 30%; display: inline-block; margin-left: 2.9%; }
@media (max-width: 979px) { form.pls_search_form_listings .search-item { margin-bottom: 5px; } }
form.pls_search_form_listings .search-item label { float: left; width: 100%; }
@media (min-width: 768px) and (max-width: 979px) { form.pls_search_form_listings .search-item { margin-left: 2%; } }
@media (max-width: 767px) { form.pls_search_form_listings .search-item { margin-left: 2%; width: 47%; } }
@media (max-width: 420px) { form.pls_search_form_listings .search-item { margin-left: 2%; width: 97%; } }
form.pls_search_form_listings .search-item select, form.pls_search_form_listings .search-item .chzn-container { width: 80% !important; }
<div style="clear:both"></div></div>
<script>
var neighborhoods = {
"Sea Pines": [
"Club Course",
"Harbour Town",
"Ocean Course",
"Ocean Side",
"Heron Pointe/Sea Marsh Course",
"South Beach",
],
"Forest Beach": [
"North Forest Beach",
"South Forest Beach"
],
"Shipyard":[],
"Wexford":[],
"Long Cove":[],
"Palmetto Dunes/Shelter Cove":[
"Inverness Side",
"Leamington",
"Mariners Side",
"Shelter Cove"
],
"Folly Field":[],
"Port Royal":[
"Barony Course",
"Ocean Side Port Royal Drive",
"Robbers Row Course",
"Sound Side Port Royal Drive"
],
"Hilton Head Plantation":[
"Bear Creek Course",
"Country Club of Hilton Head",
"Dolphin Head Course",
"Oyster Reef Course",
"Shell Streets",
"w/in 1/2 mile of Country Club"
],
"Palmetto Hall":[],
"Indigo Run":[
"Broad Point",
"Golden Bear",
"Golf Club",
"River Club"
],
"Spanish Wells":[],
"Windmill Harbour":[],
"HH/Off Plantation":[
"Broad Creek Area",
"Chaplin",
"Fish Haul",
"Jonesville",
"Marshland Road",
"Palmetto Bay",
"Palmetto Headlands",
"Point Comfort",
"Spanish Wells Road",
"Wild Horse/Squire Pope",
"Beach City Road",
"Mitchelville",
"Singleton by the Beach"
],
"Daufuskie Island":[
"Bloody Point",
"Melrose",
"Haig Point",
"Oak Ridge",
"Historical",
"Cedar Cove"
],
"Bluffton/Off Plantation":[
"170 North to Oldfield",
"170 South to 46",
"Alljoy Rd Area",
"Burnt Church Rd to Simmonsville" ,
"Downtown Bluffton",
"Gibbet Rd to Jasper County",
"Graves Bridge to Burnt Church Rd",
"Pinckney Colony",
"Pritchardville",
"Simmonsville Rd to 170",
"Simmonsville Rd to Gibbet Rd",
"Bluffton: Buckwalter Parkway",
"Old Carolina/The Traditions"
],
"Moss Creek":[],
"Colleton River":[],
"Belfair":[],
"Rose Hill":[
"Estate Side",
"Golf Course Side"
],
"Berkeley Hall":[],
"Palmetto Bluff":[],
"Sun City/Riverbend":[
"Sun City",
"RiverBend"
],
"Oldfield":[],
"Callawassie Island":[],
"Spring Island":[],
"Beauf.Co - N. of Broad River":[],
"Beauf.Co - S. of Broad River":[
"Beaufort-South of Broad River",
"Oldfield to Beaufort",
"Heywart Point",
"Chechessee Creek Club"
],
"Dataw Island":[],
"Hampton Hall":[],
"Hampton Pointe" :[],
"Hilton Head Lakes" :[],
"Hampton Lake":[],
"Jasper County":[
"Hardeeville",
"Levy",
"Ridgeland",
"170 to 195",
"Gillisonville",
"Pineland",
"Tillman",
"Bees Creek",
"The Settings at Mackays Point"
],
"Barnwell County":[],
"Colleton County":[],
"Hamption County":[],
"Orangeburg County":[],
"Bamberg County":[],
"Hilton Head South":[],
"Hilton Head South":[],
"Hilton Head Northwest":[],
"Off Island":[]
};
function createOption(key,value){
return '<option value="' + value +'">' + key + '</option>';
};
function buildOptions(parent, childArray){
output= createOption(parent,parent);
childArray.forEach(function(child){
output+=createOption('-- '+ child, child);
});
return output;
};
for (hood in neighborhoods) {
jQuery("#hoodselect").append(buildOptions(hood,neighborhoods[hood]));
}
jQuery("#hoodselect").change(function () {
str = jQuery("#hoodselect").val();
if(neighborhoods.hasOwnProperty(str)){
jQuery("#location-neighborhood").val(str);
jQuery("#metadata-subdivision").val("");
} else {
jQuery("#location-neighborhood").val("");
jQuery("#metadata-subdivision").val(str);
}
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.