html - Update javascript table: Uncaught TypeError: Object [object Object] has no method 'tableRow' -


i'm making contacts app updates table users input cant seem table update once input data error above. not sure how i've change method to, i've tried lots of different functions etc. no luck. help.

var namefield, addressfield, emailfield, postcodefield;  function twodigit(v){ if(v.tostring().length < 2){     return "0"+v.tostring(); } else {     return v.tostring(); } }  var contact = function(name, address, email, postcode){ this.name = name; this.address = address; this.email = email; this.postcode = postcode; this.completed = false; };  var contacts = [];  contact.prototype.tostring = function(){ var s = this.name + '\n' + this.address + '\n' + this.email + + '/n'   +  this.postcode.tostring() + '\n'; if(this.completed){     s += "completed\n\n"; } else {     s += "not completed\n\n"; } return s; };  var addcontact = function(namefield, addressfield, emailfield, postcodefield){ = new contact(namefield.value, addressfield.value,  emailfield.value, postcodefield.value); contacts.push(a); };  var clearui = function(){ var white = "#fff"; namefield.value = ""; namefield.style.backgroundcolor = white; addressfield.value = ""; addressfield.style.backgroundcolor = white; emailfield.value = ""; emailfield.style.backgroundcolor = white; postcodefield.value = ""; postcodefield.style.backgroundcolor = white;  };  var updatelist = function(){ var tablediv = document.getelementbyid("table"),     table = "<table border='1'><thead><th>name</th> <th>address</th><th>email</th><th>postcode</th><th>completed</th></thead>";  for(var i=0, j=contacts.length; i<j; i++){     var contacts1 = contacts[i];      table += contacts1.tablerow(); } table+="</table>"; tablediv.innerhtml = table; };  var add = function(){ addcontact(namefield, addressfield, emailfield, postcodefield); clearui(); updatelist(); };  var cancel = function(){ clearui(); updatelist(); };  window.onload = function(){ namefield = document.getelementbyid("name"); addressfield = document.getelementbyid("address"); emailfield = document.getelementbyid("email"); postcodefield = document.getelementbyid("postcode"); okbutton = document.getelementbyid("ok"); okbutton.onclick = add; cancelbutton = document.getelementbyid("cancel"); cancelbutton.onclick = cancel; clearui(); };   var showtable = function(){ var tablediv = document.getelementbyid("table"),     table = "<table border='1'><thead><th>name</th> <th>address</th><th>email</th>  <th>postcode</th></thead>";  for(var i=0, j=contacts.length; i<j; i++){     var contacts1 = contacts[i];     table += contacts1.tablerow(); } table+="</table>"; tablediv.innerhtml = table; }; 


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -