Here is your error :
<button id="btndelete" text="DELETE" />;
this line should be wrapped inside quotes.
here is the correct code :
replace above line with :
tableContents += "<td><button id='btndelete_"+ i + "' text='DELETE'>Delete</button></td>";
Good luck.