我正在开发这个天气应用程序,但我遇到了一个问题,我无法从数据集中获取特定的是否条件到屏幕上。它总是显示其中一个城市的是否条件,而不是其他城市。如果可能的话,我需要一些帮助,如果你指出我犯的任何错误,这可能是一个很大的帮助。
//The variables
var low = getColumn("Daily Weather", "Low Temperature");
var high = getColumn("Daily Weather", "High Temperature");
var city = getColumn("Daily Weather", "City");
var icon = getColumn("Daily Weather", "Icon");
var condition = getColumn("Daily Weather", "Main Condition");
var forecastNum = getColumn("Daily Weather", "Forecast Number");
var id = 0;
//filtered variables
var todayLow = [];
var todayHigh = [];
var todayCondition = [];
var todayIcon = [];
onEvent("locationDropdown", "change", function( ) {
if (getText("locationDropdown") == "Anchorage, Alaska") {
id = 1;
} else if ((getText("locationDropdown") == "Fairbanks, Alaska")) {
id = 6;
} else if ((getText("locationDropdown") == "Denver/Boulder, Colorado")) {
id = 16;
} else if ((getText("locationDropdown") == "Chicago, Illinois")) {
id = 31;
} else if ((getText("locationDropdown") == "Des Moines, Iowa")) {
id = 56;
} else if ((getText("locationDropdown") == "Goodland, Kansas")) {
id = 66;
} else if ((getText("locationDropdown") == "Louisville, Kentucky")) {
id = 86;
} else {
id = 96;
}
});
onEvent("conditionButton", "click", function( ) {
updateScreen();
setScreen("screen2");
});
onEvent("conditionButton1", "click", function( ) {
updateScreen();
setScreen("screen2");
});
onEvent("tempButton", "click", function( ) {
updateScreen();
setScreen("screen3");
});
onEvent("homeButton1", "click", function( ) {
updateScreen();
setScreen("screen1");
});
onEvent("homeButton2", "click", function( ) {
updateScreen();
setScreen("screen1");
});
onEvent("temperatureButton", "click", function( ) {
updateScreen();
setScreen("screen3");
});
function updateScreen() {
var index = id;
console.log(id);
for (var i = 0; i < 8; i++) {
if (forecastNum[i] == 1) {
appendItem(todayLow, low[i]);
appendItem(todayHigh, high[i]);
appendItem(todayCondition, condition[i]);
appendItem(todayIcon, icon[i]);
}
}
setText("lowTemp", todayLow[1]);
setText("highTemp", todayHigh[1]);
setText("label2", todayCondition[1]);
setProperty("image2", "image", todayIcon[1]);
console.log(idNum);
console.log(index);
console.log(todayLow);
}
=