2015-06-05 34 views
0

这是什么,它是什么意思,为什么我看到这个?我正在制作出席应用程序,当我实时预览时,我会看到Uncaught SyntaxError:意外的标记{。出勤应用程序未捕获SyntaxError:意外的令牌{

function save() { 
var first = document.getElementById('sFirstName'); 
var last = document.getElementById('sLastName'); 
var numb = document.getElementById('sNumber'); 
var pts = document.getElementById('pnts'); 
} 

它似乎只出现在下面的行。

var studentInfo{ 

但不能在此行

first: document.getElementById('sFirstName').value, 
last: document.getElementById('sLastName').value, 
numb: document.getElementById('sNmber').value, 
pnts: document.getElementById('pts').value 
} 
var newobj = [studentInfo]; 
     localStorage.setItem("student", JSON.stringify(studentInfo)); 
newobj = JSON.parse(localStorage.getItem("student")); 
/*localStorage.setItem("studentInfo", JSON.stringify(studentInfo[index].value; 
index = index + 0; 
}*/ 
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); 
        cell5 = row.insertCell(4); 
        cell6 = row.insertCell(5); 
        cell7 = row.insertCell(6); 

    cell1.innerHTML = studentInfo[index].firstName + studentInfo[index].lastName 
    cell2.innerHTML = studentInfo[index].studentNumber; 
    cell3.innerHTML = studentInfo[index].pnts; 
} 



function userName() { //this function takes values from the text box and stores them in objects 

    var studentInfo = { 
     studentNumber: document.getElementById("newUser").value + index, 
     lastName: document.getElementById("newlName").value + index, 
     firstName: document.getElementById("newfName").value + index 

    }; 
} 

代码是为了从我如何它写。

回答

1

的语法应该是

var studentInfo = {... 
       ^^^^ 

你缺少赋值运算符

0

“代码是按照我的写法编写的。”不它不是。

var studentInfo{ 

确实是错了

var studentInfo = {}; 

应该让你的生活earier

相关问题