i have drop down dependancy for contry ,state and city
i want to update thouse detail means it's show the first array value it not show the database value
This is my javascript code
var states = new Array();
states['United States'] = new Array('Alabama', 'Alaska', 'Arizona');
states['India'] = new Array('Andhra Pradesh', 'Arunachal Pradesh', 'Assam');
var cities = new Array();
cities['United States'] = new Array();
cities['United States']['Alabama'] = new Array('Birmingham', 'Montgomery', 'Mobile', 'Huntsville');
cities['United States']['Alaska'] = new Array('Tucson', 'Anchorage');
cities['United States']['Arizona'] = new Array('Chandler', 'Phoenix', 'Mesa', 'Glendale', 'Scottsdale', 'Gilbert', 'Tempe', 'Peoria', 'Surprise');
cities['India'] = new Array();
cities['India']['Andhra Pradesh'] = new Array('Adilabad', 'Adoni', 'Amadalavalasa', 'Amalapuram', 'Ameenapuram', 'Anakapalle', 'Anantapur','Warangal', 'Yellandu', 'Yemmiganur', 'Yerraguntla', 'Zahirabad');
cities['India']['Arunachal Pradesh'] = new Array('Along', 'Bomdila', 'Itanagar*', 'Naharlagun', 'Pasighat');
cities['India']['Assam'] = new Array('Abhayapuri', 'Amguri', 'Anandnagaar', 'Barpeta', 'Barpeta Road', 'Bilasipara','Nalbari', 'North Lakhimpur', 'Rangia', 'Sibsagar', 'Silapathar', 'Silchar', 'Tezpur', 'Tinsukia');
function setStates() {
cntrySel = document.getElementById('ddlCountry');
stateList = states[cntrySel.value];
changeSelect('ddlState', stateList, stateList);
setCities();
}
function setCities() {
cntrySel = document.getElementById('ddlCountry');
stateSel = document.getElementById('ddlState');
cityList = cities[cntrySel.value][stateSel.value];
changeSelect('ddlCity', cityList, cityList);
}
function changeSelect(fieldID, newOptions, newValues) {
selectField.options.length = 0;
for (i = 0; i < newOptions.length; i++) {
selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]);
}
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function () {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function () {
setStates();
});