-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateTable.js
40 lines (27 loc) · 1005 Bytes
/
createTable.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function createTable(){
var name = ["Name",""];
name.push(document.form15.studentName.value);
var age = ["Age",""];
age.push(document.form15.studentAge.value);
var degree = ["Degree",""];
degree.push(document.form15.studentDegree.value);
var tab = document.createElement("table");
tab.setAttribute("border", "1");
tab.id = "tableStudents";
document.getElementById("tableArea").appendChild(tab);
var tbdy = document.createElement("tbody");
tab.appendChild(tbdy);
for (var i=0; i<name.length; i++) {
var tr = document.createElement("tr");
tbdy.appendChild(tr);
var tdName = document.createElement("td");
tdName.appendChild(document.createTextNode(name[i]));
tr.appendChild(tdName);
var tdAge = document.createElement("td");
tdAge.appendChild(document.createTextNode(age[i]));
tr.appendChild(tdAge);
var tdDegree = document.createElement("td");
tdDegree.appendChild(document.createTextNode(degree[i]));
tr.appendChild(tdDegree);
}
}