我正在我的学校和我的javascript中为这个项目编程,我一直收到这个错误。请帮忙。非常感谢。
var table,row,cell1,cell2,cell3 {
table=document.getElementById("onlineAttendance");
studentInfo= JSON.parse(localStorage.getItem("studentRecord"));
}
function myFunction() {
alert ("Your attendence is submitted");
}
function studentAttendance () {
for (var index=0;index<studentInfo.length;index++) {
row=table.insertRow(index+1);
cell1=row.insertCell(0);
cell2=row.insertCell(1);
cell3=row.insertCell(2);
cell4=row.insertCell(3);
cell1.innerHTML=studentInfo[0].studentNumber;
cell2.innerHTML=studentInfo[0].firstName+" "+
studentInfo[0].lastName;
cell3.innerHTML=studentInfo[0].absent;
for (i=0; i<length; i++)
if (!document.getElementById(absent).checked)
{
studentInfo.points++;
}
答案 0 :(得分:0)
有几个问题,首先在var声明后需要一个分号。你也在进行不必要的块包装(但这不是一个真正的问题,除了在尝试调试时,因为缩进应该是每个人都关心的问题。)
最后你没有关闭最后一个function
和for
循环(忽略缩进)。但如果您忘记在创建问题时忘记复制它们,那么您可能不需要它们。
var table,row,cell1,cell2,cell3;
{
table=document.getElementById("onlineAttendance");
studentInfo= JSON.parse(localStorage.getItem("studentRecord"));
}
function myFunction() {
alert ("Your attendence is submitted");
}
function studentAttendance () {
for (var index=0;index<studentInfo.length;index++) {
row=table.insertRow(index+1);
cell1=row.insertCell(0);
cell2=row.insertCell(1);
cell3=row.insertCell(2);
cell4=row.insertCell(3);
cell1.innerHTML=studentInfo[0].studentNumber;
cell2.innerHTML=studentInfo[0].firstName+" "+
studentInfo[0].lastName;
cell3.innerHTML=studentInfo[0].absent;
for (i=0; i<length; i++)
if (!document.getElementById(absent).checked)
{
studentInfo.points++;
}
}
}
}