Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

#1050 UI:Change behaviour of address field in signup admin page #1098

Closed
wants to merge 14 commits into from
Closed
24 changes: 22 additions & 2 deletions vms/vms/static/vms/js/load_city.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
/** Fetches cities belonging to selected state and country */
$(document).ready(function() {
$("#select_state").change(function() {
/* Disables the city input field until the state input is filled up */
function hideCity(){
var state =document.getElementById("select_state");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have jquery already, use $ instead of document.getElementBy-.

if(state.disabled===false && state.value!==null && state.value!=="0") {
document.getElementById("select_city").disabled=false;
}
else {
document.getElementById("select_city").disabled=true;
}
}
hideCity();

/** Fetches cities belonging to selected state and country */
var countryId = $("#select_country").val();
var stateId = $(this).val();
$.ajax({
Expand All @@ -10,8 +22,16 @@ $(document).ready(function() {
"state": stateId
},
success: function(cities) {
$("#select_city").html(cities);
var state=$("#select_state");
if(state.val()!=="0" && state.val()!==null && state.prop('disabled')===false)
$("#select_city").html(cities);
else
$("#select_city").empty();
}
});


});

});

48 changes: 43 additions & 5 deletions vms/vms/static/vms/js/load_state.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
/** Fetches states belonging to selected country */
$(document).ready(function() {
$("#select_country").change(function() {
/* Disables the city and state input field until the country input is filled up */
function hideState(){
var country =document.getElementById("select_country").value;
var state =document.getElementById("select_state").value;
if(country==="0") {
document.getElementById("select_state").disabled='disabled';
document.getElementById("select_city").disabled='disabled';
}
if (country!=="0"){
document.getElementById("select_state").disabled=false;
}
if(state.disabled===false && state.value!==null && state.value!=="0") {
document.getElementById("select_city").disabled=false;
}
else {
document.getElementById("select_city").disabled=true;
document.getElementById("select_city").value=null;
}
}
hideState();

/** Fetches states belonging to selected country */
var countryId = $(this).val();
$.ajax({
url: CheckState,
Expand All @@ -16,9 +37,15 @@ $(document).ready(function() {
"state": 0
},
success: function(cities) {
$("#select_city").html(cities);
$("#select_state").empty();
}
var state=$("#select_state");
if(state.val()!=="0" && state.val()!==null && state.prop('disabled')===false)
$("#select_city").html(cities);
else
$("#select_city").empty();
$("#select_state").empty();

},

});
} else if (statecheck === true) {
$.ajax({
Expand All @@ -29,11 +56,22 @@ $(document).ready(function() {
success: function(states) {
$("#select_state").html(states);
$("#select_city").empty();

}
});
}
}
});
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this extra space.

});

});


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these extra lines.