Write and create table to page - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:TableData

Description

Write and create table to page

Demo Code

ResultView the demo in separate window

<html>
   <head> 
   </head>/*  w ww .  j a  v a2 s  .  c  o  m*/
   <body>
      <form> 
         <script language="JavaScript">
 document.write("<table border='2' width='30%'>");
 document.write("<tr><th>X</th><th>Y</th><th>X*Y</th></tr>");
 for(i=1;i<=10;i++)
 {
   document.write("<tr><td>"+i+"</td>"+"<td>9</td>"+"<td><input type='text' id='sum" + i +"'></td></tr>");
   var x=i*9;
   document.getElementById("sum" + i).value=x;
 }
 document.write("</table>");

         </script>   
      </form>
   </body>
</html>

Related Tutorials