-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakerow.js
50 lines (47 loc) · 1.57 KB
/
makerow.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
38
39
40
41
42
43
44
45
46
47
48
49
function make_row(cellInfo) {
// Returns a TR element with necessary TD children to be attached to a document.
var r = document.createElement('tr');
for (var i = 0; i < cellInfo.length; i++) {
var cur = cellInfo[i];
var new_cell = document.createElement('td');
var content = document.createElement('p');
if (cur.type === 'inputText'){
content = document.createElement("input");
content.type = "text";
content.value = cur.val;
}
else if (cur.type === "inputAddr") {
// attach function for when text box is selected
//x.parentElement.children[1].children[0].value
content = document.createElement("input");
content.type = "text";
content.value = cur.val;
}
else if (cur.type === "selectMenu"){
content = document.createElement("select");
for (var j = 0; j < cur.val[0].length; j++) {
content.options.add( new Option(cur.val[0][j], cur.val[0][j]) );
}
content.value = cur.val[1];
}
else if (cur.type === "checkBox") {
content = document.createElement("input");
content.type = "checkbox";
content.checked = cur.val;
}
else if (cur.type === "radio") {
content = document.createElement("input");
content.type = "radio";
content.setAttribute('name', cur.val[0]);
content.checked = cur.val[1];
}
else if (cur.type == null) {
content = document.createElement('p');
//console.log(cur);
content.innerHTML = cur;//['val'];
}
new_cell.appendChild(content);
r.appendChild(new_cell);
}
return r;
}