Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show Hong Kong districts when the Country field changes to "Hong Kong".
<script type="text/javascript">
// SalsaStaff 126206: Change the State options to be the Hong Kong districts as needed.
// @see https://salsasupport.zendesk.com/entries/99164537
// @see https://en.wikipedia.org/wiki/Districts_of_Hong_Kong
$(document).ready(function() {
var country = $('*[name=Country]');
if (country.length != 0) {
country.change(function() {
if (country.val() == 'HK') {
$('*[name=State]')
.empty()
.append($('#hong-kong-districts').children());
}
});
}
})
</script>
<select style="display: none;" id="hong-kong-districts">
<option value="">Please choose a district</option>
<option value="Central and Western">Central and Western</option>
<option value="Eastern">Eastern</option>
<option value="Islands">Islands</option>
<option value="Kowloon City">Kowloon City</option>
<option value="Kwai Tsing">Kwai Tsing</option>
<option value="Kwun Tong">Kwun Tong</option>
<option value="North">North</option>
<option value="Sai Kung">Sai Kung</option>
<option value="Sha Tin ">Sha Tin </option>
<option value="Sham Shui Po">Sham Shui Po</option>
<option value="Southern">Southern</option>
<option value="Tai Po">Tai Po</option>
<option value="Tsuen Wan">Tsuen Wan</option>
<option value="Tuen Mun">Tuen Mun</option>
<option value="Wan Chai">Wan Chai</option>
<option value="Wong Tai Sin">Wong Tai Sin</option>
<option value="Yau Tsim Mong">Yau Tsim Mong</option>
<option value="Yuen Long">Yuen Long</option>
</select>
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.