[英]Javascript “Uncaught TypeError: object is not a function”
Code is as follows: 代码如下:
function change_course(ref)
{
var arr = ref.split(/\^/);
document.getElementById('course').value = arr[0];
document.getElementById('course_date').value = arr[1];
}
This will throw an "Uncaught TypeError: object is not a function". 这将引发“未捕获的TypeError:对象不是函数”。
<select name="change_course" class="form-control" onChange="change_course(this.value);">';
Where is wrong 哪里错了
Inline onchange
is executed within the same scope as the form
element (or inner), and change_course
refers to the select
element, not to the global function. 内联onchange
在与form
元素(或inner元素)相同的范围内执行,并且change_course
引用select
元素,而不是全局函数。
To fix this, just give a new value to select
's name
attribute, or rename the function. 要解决此问题,只需提供一个新值以select
的name
属性,或重命名该函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.