Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Data for the "HTML Tables" Page
- var users = [
- {first_name: "Kaitlin", last_name: "Burns", age: 23, email: "kburns99753@usermail.com"},
- {first_name: "Joshua", last_name: "Feir", age: 31, email: "josh319726@usermail.com"},
- {first_name: "Stephen", last_name: "Shaw", age: 28, email: "steve.shaw47628@usermail.com"},
- {first_name: "Timothy", last_name: "McAlpine", age: 37, email: "Timbo72469@usermail.com"},
- {first_name: "Sarah", last_name: "Connor", age: 19, email: "SarahC6320@usermail.com"}
- ];
- function table1() {
- var find = document.querySelector("#table");
- var tbl = document.createElement("table");
- var row = document.createElement("tr");
- var cell = document.createElement("th");
- var cell1 = document.createElement("th");
- var cell2 = document.createElement("th");
- var cell3 = document.createElement("th");
- var cellText = document.createTextNode("First Name");
- var cellText1 = document.createTextNode("Last Name");
- var cellText2 = document.createTextNode("Age");
- var cellText3 = document.createTextNode("Email");
- cell.appendChild(cellText);
- cell1.appendChild(cellText1);
- cell2.appendChild(cellText2);
- cell3.appendChild(cellText3);
- row.appendChild(cell);
- row.appendChild(cell1);
- row.appendChild(cell2);
- row.appendChild(cell3);
- tbl.appendChild(row);
- find.appendChild(tbl);
- tbl.setAttribute("border", "1");
- for (var j = 0; j < users.length; j++) {
- var row1 = document.createElement("tr");
- var link = document.createElement("a");
- link.setAttribute("href", "mailto:" + user[j].email);
- var txt = document.createTextNode(users[j].email);
- link.appendChild(txt);
- var tbld1 = document.createElement("td");
- var tbld2 = document.createElement("td");
- var tbld3 = document.createElement("td");
- var tbld4 = document.createElement("td");
- var fname = document.createTextNode(users[j].first_name);
- var lname = document.createTextNode(users[j].last_name);
- var age = document.createTextNode(user[j].age);
- tbld1.appendChild(fname);
- row1.appendChild(tbld1);
- tbld2.appendChild(lname);
- row1.appendChild(tbld2);
- tbld3.appendChild(age);
- row1.appendChild(tbld3);
- tbld4.appendChild(link);
- row1.appendChild(tbld4);
- tbl.appendChild(row1);
- }
- find.appendChild(tbl);
- }
- window.onload = function () {
- table1();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement