Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / tables / mozilla / dom / tableDom.html
blob60bf90a50320c8661b0ea225037bc046e06d5c35
1 <HEAD>
2 <SCRIPT src=dom.js>
3 </SCRIPT>
4 <SCRIPT>
6 var count = 1;
7 function genName(prefix) {
8 return "X" + count++ + "\n";
11 function doIt() {
12 var rgInput = document.getElementsByTagName("INPUT")[0];
13 var rgIndex = rgInput.value;
14 var rowInput = document.getElementsByTagName("INPUT")[1];
15 var rowIndex = rowInput.value;
16 var colInput = document.getElementsByTagName("INPUT")[2];
17 var colIndex = colInput.value;
18 var rowSpanInput = document.getElementsByTagName("INPUT")[3];
19 var rowSpan = rowSpanInput.value;
20 var colSpanInput = document.getElementsByTagName("INPUT")[4];
21 var colSpan = colSpanInput.value;
22 var select = document.getElementsByTagName("SELECT")[0];
23 var actionIndex = select.selectedIndex;
25 var table = document.getElementsByTagName("TABLE")[0];
26 var tbodies = table.tBodies;
27 var tbody = tbodies.item(rgIndex);
30 if (0 == actionIndex) {
31 var rows = tbody.rows;
32 var row = rows.item(rowIndex);
33 //appendCell(rowIndex, rowSpan, colSpan);
34 appendCell(row, 1, 1);
36 else if (1 == actionIndex) {
37 var rows = tbody.rows;
38 var row = rows.item(rowIndex);
39 //insertCell(rowIndex, colIndex, rowSpan, colSpan);
40 insertCell(row, colIndex, 1, 1);
42 else if (2 == actionIndex) {
43 var rows = tbody.rows;
44 var row = rows.item(rowIndex);
45 deleteCell(row, colIndex);
47 else if (3 == actionIndex) {
48 appendRow(tbody);
50 else if (4 == actionIndex) {
51 insertRow(tbody, rowIndex);
53 else if (5 == actionIndex) {
54 deleteRow(tbody, rowIndex);
56 else if (6 == actionIndex) {
57 buildTable(rowIndex, colIndex);
61 function appendCellx(aRowIndex, aRowSpan, aColSpan) {
62 var row = document.getElementsByTagName("TR")[aRowIndex];
63 var cell = document.createElement("TD", null);
64 cell.rowSpan = 2;
65 cell.colSpan = aColSpan;
66 var text = document.createTextNode(genName());
67 cell.appendChild(text);
68 row.appendChild(cell);
71 function insertCell(aRowIndex, aColIndex, aRowSpan, aColSpan) {
72 dump(aRowSpan); dump(aColSpan);
73 var row = document.getElementsByTagName("TR")[aRowIndex];
74 //var refCell = document.getElementsByTagName("TD")[0];
75 var cells = row.cells;
76 var refCell = cells.item(aColIndex);
77 var newCell = document.createElement("TD", null);
78 newCell.rowSpan = aRowSpan;
79 newCell.colSpan = aColSpan;
80 var text = document.createTextNode(genName());
81 newCell.appendChild(text);
82 row.insertBefore(newCell, refCell);
83 //dump("SCRIPT: inserted CELL as first cell in first row\n");
86 function deleteCell(aRowIndex, aColIndex) {
87 var row = document.getElementsByTagName("TR")[aRowIndex];
88 row.deleteCell(aColIndex);
91 function appendRow(aRowGroupIndex) {
92 var rg = document.getElementsByTagName("TBODY")[aRowGroupIndex];
93 var row = document.createElement("TR", null);
94 rg.appendChild(row);
95 appendCell(row.rowIndex, 1, 1);
98 function insertRow(aRowGroupIndex, aRowIndex) {
99 var rg = document.getElementsByTagName("TBODY")[aRowGroupIndex];
100 var refRow = document.getElementsByTagName("TR")[aRowIndex];
101 var row = document.createElement("TR", null);
102 rg.insertBefore(row, refRow);
105 function buildTable(aNumRows, aNumCols) {
106 var table = document.getElementsByTagName("TABLE")[0];
107 for (rowX = 0; rowX < aNumRows; rowX++) {
108 var row = document.createElement("TR", null);
109 for (colX = 0; colX < aNumCols; colX++) {
110 var cell = document.createElement("TD", null);
111 var text = document.createTextNode(genName());
112 cell.appendChild(text);
113 row.appendChild(cell);
115 table.appendChild(row);
119 </SCRIPT>
120 </HEAD>
121 <BODY>
122 <form>
123 <select>
124 <option>append cell</option>
125 <option>insert cell</option>
126 <option>delete cell</option>
127 <option>append row</option>
128 <option>insert row</option>
129 <option>delete row</option>
130 <option>build table</option>
131 </select>
132 &nbsp tbody
133 <input type=text size=5 value=0>
134 &nbsp row
135 <input type=text size=5 value=0>
136 &nbsp col
137 <input type=text size=5 value=0>
138 &nbsp row span
139 <input type=text size=5 value=1>
140 &nbsp col span
141 <input type=text size=5 value=1>
142 &nbsp &nbsp
143 <INPUT TYPE="button" NAME="doIt" VALUE="Do It" onClick="doIt()" width=100>
144 </form>
145 <BR>
146 <table bgcolor=orange border>
147 <tbody>
148 <tr>
149 <td>c11</td>
150 </tr>
151 <tr>
152 <td>c21</td><td>c22</td>
153 </tr>
154 </tbody>
155 </table>
156 <BR>
158 </BODY></HTML>