|
<!-- BEGIN insert Montegro into the country field. --> |
|
<script type="text/javascript"> |
|
(function() { |
|
//Add Montegro to the country list. |
|
function addMontenegro() { |
|
var c = document.querySelector("select[name=Country]"); |
|
if (c != null) { |
|
var m = c.querySelector("option[value=ME]"); |
|
if (m == null) { |
|
m = c.querySelector("option[value=MS]"); |
|
if (m == null) { |
|
console.log("Unable to find Montserrat. Can't insert Montenegro. Sorry..."); |
|
return |
|
} else { |
|
var e = document.querySelector("#montenegro"); |
|
if (e != null) { |
|
c.insertBefore(e, m) |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
// Default the country to the US. |
|
function defaultToUS() { |
|
var c = document.querySelector("select[name=Country]"); |
|
if (c != null) { |
|
document.querySelector("select[name=Country]").value = "US" |
|
} |
|
} |
|
|
|
// Replace states with Montegro states. |
|
function replaceStates() { |
|
s = document.querySelector("select[name=State]") |
|
if (s != null) { |
|
var a = Array.from(document.querySelectorAll("#montenegro-states option")); |
|
if (a.length != 0) { |
|
while (s.firstChild != null) { |
|
s.removeChild(s.firstChild) |
|
} |
|
a.forEach(function(e) { |
|
s.appendChild(e.cloneNode()); |
|
}) |
|
} |
|
s.selectedIndex = 0; |
|
} |
|
} |
|
|
|
document.addEventListener("DOMContentLoaded", function() { |
|
// Wait for the country to be Montenegro, then populate the states. |
|
var c = document.querySelector("select[name=Country]"); |
|
if (c != null) { |
|
addMontenegro() |
|
defaultToUS() |
|
c.addEventListener("change", function() { |
|
//Salsa changes the country a lot. This makes sure that Montenegro |
|
//appears after the country field is refreshed. |
|
addMontenegro(); |
|
|
|
//If the country is currently Montenegro, then the states need to change. |
|
if (c.value == "ME") { |
|
replaceStates(); |
|
|
|
} |
|
}) |
|
} |
|
}); |
|
})(); |
|
</script> |
|
<div style="display:none;"> |
|
<select> |
|
<option id="montenegro" value="ME">Montenegro</option> |
|
</select> |
|
<select id="montenegro-states"> |
|
<option value="">Select a state or province</option> |
|
<option value="Andrijevica">Andrijevica</option> |
|
<option value="Bar">Bar</option> |
|
<option value="Berane">Berane</option> |
|
<option value="Bijelo Polje">Bijelo Polje</option> |
|
<option value="Budva">Budva</option> |
|
<option value="Cetinje">Cetinje</option> |
|
<option value="Danilovgrad">Danilovgrad</option> |
|
<option value="Gusinje">Gusinje</option> |
|
<option value="Herceg Novi">Herceg Novi</option> |
|
<option value="Kolašin">Kolašin</option> |
|
<option value="Kotor">Kotor</option> |
|
<option value="Mojkovac">Mojkovac</option> |
|
<option value="Nikšić">Nikšić</option> |
|
<option value="Petnjica">Petnjica</option> |
|
<option value="Plav">Plav</option> |
|
<option value="Plužine">Plužine</option> |
|
<option value="Pljevlja">Pljevlja</option> |
|
<option value="Podgorica">Podgorica</option> |
|
<option value="Rožaje">Rožaje</option> |
|
<option value="Šavnik">Šavnik</option> |
|
<option value="Tivat">Tivat</option> |
|
<option value="Ulcinj">Ulcinj</option> |
|
<option value="Žabljak">Žabljak</option> |
|
</select> |
|
</div> |
|
<!-- END insert Montegro into the country field. --> |