1//var country_arr = new Array("United States", "Canada","Other"); 2var country_arr = new Array("United States", "Canada", "Afghanistan", "Aland Islands", "Albania", "Algeria", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia, Plurinational State of", "Bonaire, Sint Eustatius and Saba", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Chinese Taipei", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Curaçao", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (Vatican City State)", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran, Islam
2ic Republic of", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic People's Republic of", "Korea, Republic of", "Kuwait", "Kyrgyzstan", "Lao People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia, the former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Moldova, Republic of", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Norway", "Oman", "Pakistan", "Palestinian Territory, Occupied", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Barthélemy", "Saint Helena, Ascension and Tristan da Cunha", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten (Dutch part)", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela, Bolivarian Republic of", "Viet Nam", "Virgin Islands, British", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe"); 3 4// States 5var s_a = new Array(); 6s_a[0]=""; 7s_a[1]="Armed Forces Europe|Alaska|Alabama|Armed Forces Pacific|Arkansas|American Samoa|Arizona|California|Colorado|Connecticut|District of Columbia|Delaware|Florida|Federated Micronesia|Georgia|Guam|Hawaii|Iowa|Idaho|Illinois|Indiana|Kansas|Kentucky|Louisiana|Massachusetts|Maryland|Maine|Marshall Islands|Michigan|Minnesota|Missouri|Northern Mariana Islands|Mississippi|Montana|North Carolina|North Dakota|Nebraska|New Hampshire|New Jersey|New Mexico|Nevada|New York|Ohio|Oklahoma|Oregon|Pennsylvania|Puerto Rico|Palau|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|United States Minor Outlying Islands|Utah|Virginia|US Virgin Islands|Vermont|Washington|Wisconsin|West Virginia|Wyoming"; 8s_a[2]="Alberta|British Columbia|Manitoba|New Brunswick|Newfoundland and Labrador|Nova Scotia|Northwest Territories|Nunavut|Ontario|Prince Edward Island|Quebec|Saskatchewan|Yukon Territories"; 9 10 11function populateStates( countryElementId, stateElementId ){ 12 13 var selectedCountryIndex = document.getElementById( countryElementId ).selectedIndex; 14 console.log(selectedCountryIndex); 15 16 var x = document.getElementById(stateElementId); 17 parentDiv = x.parentNode; 18 x.remove(); 19 20 while (parentDiv.hasChildNodes()) { 21 parentDiv.removeChild(parentDiv.firstChild); 22 } 23 24 if(selectedCountryIndex > 2){ 25 // var x = document.getElementById(stateElementId); 26 // parentDiv = x.parentNode; 27 // x.remove(); 28 29 var stateElement = document.createElement('input'); 30 stateElement.className ="input-control"; 31 stateElement.Id ="state"; 32 stateElement.setAttribute("type", "hidden"); 33 stateElement.setAttribute("name", "state"); 34 stateElement.setAttribute("id", "state"); 35 stateElement.setAttribute("value", "other-country"); 36 stateElement.setAttribute("placeholder", "--Select one--"); 37 stateElement.setAttribute("maxlength", "60"); 38 parentDiv.prepend(stateElement); 39 40 // Remove sibling label 41 $('label[for="state"]').remove(); 42 } 43 else{ 44 45 var stateElement = document.getElementById( stateElementId ); 46 47 if(typeof(stateElement) != 'undefined' && stateElement != null){ 48 49 stateElement.length=0; // Fixed by Julian Woods 50 stateElement.options[0] = new Option('--Select one--',''); 51 stateElement.selectedIndex = 0; 52 53 var state_arr = s_a[selectedCountryIndex].split("|"); 54 55 for (var i=0; i<state_arr.length; i++) { 56 stateElement.options[stateElement.length] = new Option(state_arr[i],state_arr[i]); 57 } 58 } 59 else{ 60 61 var label = document.createElement('label'); 62 label.setAttribute('for', 'state'); 63 label.setAttribute('class', 'inputLabel'); 64 label.textContent = 'State/Province*'; 65 66 //parentDiv.prepend(label); // add before input 67 68 var stateElement = document.createElement('select'); 69 stateElement.className ="wpcf7-form-control wpcf7-select wpcf7-validates-as-required input-control required"; 70 stateElement.Id ="state"; 71 stateElement.setAttribute("name", "state"); 72 stateElement.setAttribute("id", "state"); 73 stateElement.setAttribute("aria-required", "true"); 74 stateElement.setAttribute("aria-invalid", "false"); 75 76 stateElement.length=0; // Fixed by Julian Woods 77 stateElement.options[0] = new Option('--Select one--',''); 78 stateElement.selectedIndex = 0; 79 80 var state_arr = s_a[selectedCountryIndex].split("|"); 81 82 for (var i=0; i<state_arr.length; i++) { 83 stateElement.options[stateElement.length] = new Option(state_arr[i],state_arr[i]); 84 } 85 86 if (!$(parentDiv).prev('label[for="state"]').length) { 87 $(parentDiv).before(label); 88 } 89 90 //$(parentDiv).before(label); 91 parentDiv.prepend(stateElement); 92 } 93 94 } 95 96} 97 98function populateCountries(countryElementId, stateElementId){ 99 // given the id of the <select> tag as function argument, it inserts <option> tags 100 var countryElement = document.getElementById(countryElementId); 101 countryElement.length=0; 102 countryElement.options[0] = new Option('--Select one--',''); 103 countryElement.selectedIndex = 0; 104 for (var i=0; i<country_arr.length; i++) { 105 countryElement.options[countryElement.length] = new Option(country_arr[i],country_arr[i]); 106 } 107 108 // Assigned all countries. Now assign event listener for the states. 109
110 if( stateElementId ){ 111 countryElement.onchange = function(){ 112 populateStates( countryElementId, stateElementId ); 113 }; 114 } 115}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.