“基本上,我在 code.org 上开发一个应用程序,有一个名为:SubmitButtonFreeClothingScreen 的按钮。单击该按钮时,它会打开一个名为“Screen2”的屏幕,其中包含一个名为“display_info”的文本框。机器进行搜索通过一个名为“FreeClothing”的数据库,我希望它搜索一个术语并显示该术语的数据。用户在一个名为“text_input1”的文本框中输入该术语。我认为下面的代码可以工作,但机器总是显示else 声明。有没有其他方法可以做到这一点?
onEvent("SubmitButtonFreeClothingScreen", "click", function(event)
{
{
setScreen("Screen2");
readRecords("FreeClothing",{ZipCodes: getText("text_input1")},
function(records)
{
var names="";
if (records.length>0)
{
for(var i =0; i < records.length; i++)
{
var number= i+1;
names=names+ number + ") " + records[i].Name+"" +"\n\n"+"Address: "+ records[i].Address+"\n\n"+"Phone Number: "+ records[i].PhoneNumber+"\n\n"+"Description: "+ records[i].Description+"\n\n";
}
setText("display_info",""+names);
}
/*Display Furniture Store information located in database*/
else
{
setText ("display_info", "This Zipcode unfortunately has no Furniture Store locations. Please try another one");
/*If no information is found, the string above is printed*/
}
}
);
}
});