Advertisement
Guest User

Untitled

a guest
Apr 16th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title> first lab </title>
  5. </head>
  6. <body>
  7. <table border="1px " style=" width:50% ; text-align:center " id="table1" >
  8.  
  9. <thead >
  10. <tr style="background-color: #4CAF50 ; height:30px">
  11. <th>name</th>
  12. <th>age</th>
  13. <th>country</th>
  14. </tr>
  15. </thead>
  16. <tbody>
  17. <tr>
  18. <td>Ahmed</td>
  19. <td>15</td>
  20. <td>Egypt</td>
  21. </tr>
  22. <tr>
  23. <td>Mohamed</td>
  24. <td>12</td>
  25. <td>USA</td>
  26. </tr>
  27. </tbody>
  28. </table>
  29. </br></br></br>
  30. Username: <input type="text" id="username"/>
  31. age: <input type="text" id="age"/>
  32. password: <input type="password" id="password"/>
  33.  
  34. <input type="submit" onclick="add_row()"/>
  35.  
  36.  
  37. <script>
  38. function add_row(){
  39. var table = document.getElementById('table1');
  40. var row1 = document.createElement("tr");
  41.  
  42. var col1 = document.createElement("td");
  43. col1.innerText= document.getElementById('username').value;
  44.  
  45. var col2 = document.createElement("td");
  46. col2.innerText = document.getElementById('age').value;
  47.  
  48. var col3 = document.createElement("td");
  49. col3.innerText = document.getElementById('password').value;
  50.  
  51.  
  52. row1.appendChild(col1);
  53. row1.appendChild(col2);
  54. row1.appendChild(col3);
  55.  
  56. table.appendChild(row1);
  57.  
  58.  
  59.  
  60.  
  61.  
  62. }
  63. </script>
  64. </body>
  65. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement