title: A function to print a html table using Javascript
body: <p>I need the <code>write()</code> function to print a html table using JavaScript,the column names should be First name,Last name and Email sequentially.I can't get the names to print in the table.Don't know what i m doing wrong.Below is my code     </p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
  &lt;title&gt;Address Book&lt;/title&gt;
  
  
  &lt;script type="text/javascript"&gt;
  function addressBookItem (fname, lname, email) {
      this.fname= fname;
      this.lname = lname; 
      this.email = email;
  }
  
  addressBookItem.prototype.write = function() {
  
      var table=document.getElementById("myTable");
      var row=table.insertRow(-1);
      var cell1=row.insertCell(0);
      var cell2=row.insertCell(1);
      var cell3=row.insertCell(2);
  
      cell1.innerHTML=this.fname;
      cell2.innerHTML=this.lname;
      cell3.innerHTML=this.email;
  
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt; 
  &lt;script type="text/javascript"&gt;
      var aB1 = new addressBookItem('Roger', 'Williams', 'rwilliams@gmail.com');
      var aB2 = new addressBookItem ('Rose', 'Schultz', 'rose_s@earthlink.net');
      aB1.write();
      aB2.write();
  &lt;/script&gt;
  &lt;table id="myTable" border="1"&gt;
  &lt;tr&gt;
  &lt;td&gt;First Name&lt;/td&gt;
  &lt;td&gt;Last Name&lt;/td&gt;
  &lt;td&gt;Email Address&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>