Although you have the remove()
function incorrect, you should also remove items in reverse order, because once an item is removed, indices are shifted.
http://jsfiddle.net/MrPolywhirl/gPY3p/
function hideCountries() {
countrymenu = document.getElementsByName('country_code')[0]
for (var i = countrymenu.length-1; i >= 0; i--) {
if (/^ASM|AIA$/.test(countrymenu.options[i].value) == false) {
countrymenu.remove(i);
}
}
}
window.onload = hideCountries();
This should leave only:
- American Samoa
- Anguilla