Skip to content

Instantly share code, notes, and snippets.

@landbryo
Last active May 23, 2018 15:07
Show Gist options
  • Save landbryo/6a2540c601fc5d515f37057ee28beaa9 to your computer and use it in GitHub Desktop.
Save landbryo/6a2540c601fc5d515f37057ee28beaa9 to your computer and use it in GitHub Desktop.
Adds hashtag to URL based on selected option.
<script>
var url = window.location.href;
if (url.search("country=") >= 0) {
window.location.hash = "#locator";
}
</script>
<a name="locator"></a>
<form>
<select name="country" id="country-menu">
<option value="">FILTER BY COUNTRY</option>
<?php foreach($countries as $key => $label) : ?>
<option value="<?=$key?>" id="<?=$key?>"<?php if ($key== $country) : ?> selected<?php endif; ?>><?=$label?></option>
<?php endforeach?>
</select>
<input type="submit" style="display:none;">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment