javascript - 添加for循环时的ReferenceError
问题描述
ReferenceError: fetchRemoteClusters is not defined
当我在我的fetchRemoteClusters
函数中添加一个 for 循环时,我感到很奇怪。当我删除 for 循环并简单地执行警报或其他任何操作时,它就可以正常工作。
我的功能看起来像这样
function fetchRemoteClusters(location)
{
var select = document.getElementById("Pantheoncluster");
var options = ["1", "2", "3", "4", "5"];
for(var i = 0; i < options.length; i++) {
var opt = options[i];
var el = document.createElement("option");
el.text = opt;
el.value = opt;
select.add(el);
}
}
这是我调用函数的地方
<input type="checkbox" id = "<?php echo $this->LOC2?>" name="<?php echo $this->LOC2?>" value="<?php echo $this->LOC2?>" onclick="fetchRemoteClusters('<?php echo $this->LOC2?>')"><?php echo $this->LOC2?>
这可能是什么原因造成的?请帮忙。
解决方案
推荐阅读
- sql - SELECT MAX(), COUNT() 返回错误值
- html - 请问如何用img调整输入文本的大小
- c++ - 了解转换运算符的 C++ 选择
- nginx - 防止 NGINX 缓冲包
- python - 如何使用 Selenium(Python)单击表格内的按钮
- angular - 如何使用来自另一个组件的对象设置选择 Angular mat-selection-list
- mysql - SSIS:来源有UNICODE数据;我正在使用 MySQL 64 位 ANSI ODBC 驱动程序
- python-2.7 - Py(os.path):是否有最大值。自动断线/返回之前的字符串大小?
- php - 使用 Angular 发布到 PHP 文件
- java - Primefaces Serenity 主题子菜单在父元素更新后停止运行