function test(results) {
//Populate the ComboBox with unique values
var Gov;
var values = [];
var features = results.features;
var og;
for (i = 0; i < features.length; i++) {
var aGOV = {
"GovName": features[i].attributes.ENG_NAME,
"GovNO": features[i].attributes.GOV_NO,
"Shape": features[i].geometry
}
og = new Option(features[i].attributes.ENG_NAME, aGOV);
var cbx = document.getElementById("cbxGov");
cbx.options.add(og);
}
}
function gov_selection_change()
{
var cbx = document.getElementById("cbxGov");
var itm = cbx.options[cbx.selectedIndex].value.hasOwnProperty("Shape");
}
HTML代码如何访问JavaScript对象属性
<select id="cbxGov" onchange="gov_selection_change()">
我的问题是我不是能够访问我的gov_selection_change(
)功能aGOV的属性时,显示它有没有这样的属性,ITM是假的。
看起来你实际上并没有试图在'goc_selection_change'中访问'aGOV'的任何属性,对吗?如果你这样做,这将超出范围。在'test'之外定义'aGOV'。 – apsillers