options: ['Unknown', 'AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE']
This is my Options Array and there are 47 states in all. i don't 开发者_StackOverflow中文版want to add it like this. Instead can i add something like this
options: [StateValue] Which would read all the values from the Object.
var StateValue = {
Unknown: 0,
AL: 1,
AK: 2,
AZ: 3,
AR: 4,
CA: 5,
CO: 6,
CT: 7,
DE: 8,
FL: 9
};
You can loop through an object like so
var StateValue = {
Unknown: 0,
AL: 1,
AK: 2,
AZ: 3,
AR: 4,
CA: 5,
CO: 6,
CT: 7,
DE: 8,
FL: 9
};
for(var i in StateValue)
console.log(i + " :: " + StateValue[i]);
so you could populate your UI in that way
精彩评论