I keep getting "Uncaught SyntaxError:Unexpected token { " in my javascript. I can't figure out why -


i programing project @ school , in javascript, keep getting error. please help. appreciated.

var table,row,cell1,cell2,cell3 { table=document.getelementbyid("onlineattendance"); studentinfo= json.parse(localstorage.getitem("studentrecord")); }  function myfunction() {     alert ("your attendence submitted"); } function studentattendance () { (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;     (i=0; i<length; i++)          if (!document.getelementbyid(absent).checked)         {             studentinfo.points++; } 

there several problems, first need semicolon after var declarations. doing unnecessary block wrapping (but not problem, except when trying debug because indentation should concern everyone).

and not closing last function , for loop (disregarding indentation). possible don't need them if forgot copy them creation of question.

var table,row,cell1,cell2,cell3;  {     table=document.getelementbyid("onlineattendance");     studentinfo= json.parse(localstorage.getitem("studentrecord")); }   function myfunction() {     alert ("your attendence submitted"); }  function studentattendance () {     (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;         (i=0; i<length; i++)              if (!document.getelementbyid(absent).checked)             {                 studentinfo.points++;             }         }     } } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -