我正在尝试创建一个接受用户输入并调用相应对象及其值的程序。
我一直收到这个错误:
未捕获的ReferenceError:未定义findStudent
HTML:
<html>
<head> </head>
<body>
<input type = "text" name = "name" id = "name">
<button type = "submit" id = "submit" onclick = "findStudent()">Find Student </button>
</body>
</html>
使用Javascript:
function Student(GPA, Faculty, Major) {
this.GPA = GPA;
this.Faculty = Faculty;
this.Major = Major;
}
var Matthew = new Student(5.0, "Science", "Cognitive Systems");
var Rohit = new Student(5.0, "Science", "Micro Biology");
var Marcel = new Student(5.0, "Engineering", "Undeclared");
var Louie = new Student(5.0, "Engineering", "Mechanical");
var Matt = new Student(5.0, "Engineering", "Mechanical");
var Petra = new Student(5.0, "Science", "Biology");
var Senara = Senny = new Student(5.0, "Science", "Biology");
var Jen = Jenny = Jennifer = new Student(5.0, "Science", "BioChemistry");
var Julia = Jules = new Student(5.0, "???", "Life");
findStudent function(){
console.log(document.getElementById('name').innerHTML);
}