<script type="text/javascript">
function passCheck(){
var pass1 = document.getElementById('password').value;
var pass2 = document.getElementById('confirmPassword').value;
if(pass1 == pass2 && pass1 != ""){
return true;
}
else{
alert("Both password inputs do not match. Please retry.");
document.getElementById('surveyorForm').reset();
return false;
}
}
function change() {
var x = document.getElementById("select").value;
(function () {
var xmlhttp = new XMLHttpRequest();
var url = "http://somejsondata?someget=" + x ;
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
myFunction(xmlhttp.responseText);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(response) {
var arr = JSON.parse(response);
var i;
var out = "<div class='form-group'>" +
"<label>City</label>" +
"<select class='form-control' name='cityId'>" +
"<option disabled selected>Select your option</option>";
for(i = 0; i < arr.length; i++) {
out += "<option value='" +
arr[i].cityId +
"'>" +
arr[i].cityName +
"</option>";
}
out += "</select>" +
"</div>";
document.getElementById("city").innerHTML = out;
}
})();
}
(function () {
var xmlhttp = new XMLHttpRequest();
var url = "http://somejsondata";
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
myFunction(xmlhttp.responseText);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(response) {
var arr = JSON.parse(response);
var i;
var out = "<div class='form-group'>" +
"<label>Province</label>" +
"<select class='form-control' id='select' name='provId' onchange='change()'>" +
"<option disabled selected>Select your option</option>";
for(i = 0; i < arr.length; i++) {
out += "<option value='" +
arr[i].provinceId +
"'>" +
arr[i].provinceName +
"</option>";
}
out += "</select>" +
"</div>";
document.getElementById("province").innerHTML = out;
}
})();
(function () {
var xmlhttp = new XMLHttpRequest();
var url = "http://somejsondata";
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
myFunction(xmlhttp.responseText);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(response) {
var arr = JSON.parse(response);
var i;
var out = "<div class='form-group'>" +
"<label>Country</label>" +
"<select class='form-control' name='countryId'>" +
"<option disabled selected>Select your option</option>";
for(i = 0; i < arr.length; i++) {
out += "<option value='" +
arr[i].countryId +
"'>" +
arr[i].countryName +
"</option>";
}
out += "</select>" +
"</div>";
document.getElementById("country").innerHTML = out;
}
})();
</script>
I already put this script right before </body>
and check the link it work resulting json data. But why when I access site it didn't show up like I before migrating website. The dropdown menu just didn't show up.
I add some errors what kind error is this
XMLHttpRequest cannot load http://gpx1.gdn/country/read. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://gpx2.gdn' is therefore not allowed access.
insertSurveyor:1 XMLHttpRequest cannot load http://gpx1.gdn/province/read. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://gpx2.gdn' is therefore not allowed access.
firebug-lite.js:11883 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.fetchResource @ firebug-lite.js:11883
firebug-lite.js:30905 Uncaught TypeError: Cannot read property 'push' of undefined(…)