Код:
|
<html>
<head>
<link rel="stylesheet" href="../labs.css">
<link rel="stylesheet" href="lab2c.css">
<script type="text/javascript" src="lab2.js"></script>
</head>
<body>
<div>
<table id="xmpl">
<thead>
<tr id="xmpl-th-tr">
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
<th>E</th>
<th>F</th>
<th>G</th>
<th>H</th>
<th>J</th>
<th>K</th>
<th>L</th>
<th>M</th>
<th>N</th>
<th>O</th>
<th>P</th>
<th>Итоги</th>
</tr>
</thead>
<tbody id="xmpl-tbd">
</tbody>
<tfoot id="xmpl-tft">
<tr id="z1">
<td colspan="4" >
<button onclick="fill()">fill</button>
</td>
<td colspan="3" >
<button onclick="rotate(a)">rotate</button>
</td>
<td colspan="3" >
<button onclick="addTr()">add tr</button>
</td>
<td colspan="3" >
<button onclick="empty()">empty tr </button>
</td>
<td colspan="3" >
<button onclick="deleteTr()">Delete</button>
</td>
</tr>
</tfoot>
</table>
<template id="xmpl-tmplt1">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</template>
<template id="xmpl-tmplt2">
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</template>
</div>
</body>
</html> |
function fill() {
// Проверяем поддерживает ли браузер тег <template>
// проверив наличие аттрибута content у элемента template
if ('content' in document.createElement('template')) {
var col = [
[0, 0.0, 0.0, 8.47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34.0],
[0, 0.0, 0.0, 0, 0, 0, 143.0, 0, 0, 0, 0, 0, 571.0, 0, 0],
[0, 36.0, 1.79 , 0, 0, 0, 45.0, 0, 0, 0, 0, 0, 107.0, 0, 0],
[0, 0.0, 0.0, 0, 0, 0, 100.0, 0, 0, 0, 0, 0, 533.0, 0, 0],
[0, 0.0, 0.0, 0, 0, 0, 71.0, 0, 0, 0, 0, 0, 571.0, 0, 0],
[0, 0.0, 0.0, 0, 0, 0, 67.0 , 0, 0, 0, 0, 0, 400.0, 0, 0],
[0, 0.0, 0.0, 0, 0, 0, 67.0 , 0, 0, 0, 0, 0, 533.0, 0, 0],
[0, 0.0, 0.0, 0, 0, 0, 132.0, 0, 0, 0, 0, 0, 579.0, 0, 0],
[0, 0.0, 0.0, 0, 0, 0, 53.0, 0, 0, 0, 0, 0, 474.0, 0, 0],
[0, 0.0, 0.0, 0, 0, 0, 100.0, 0, 0, 0, 0, 0, 533.0, 0, 0]
],
t = document.querySelector('#xmpl-tmplt1'),
td = t.content.querySelectorAll("td"),
tb = document.getElementsByTagName("tbody");
col.forEach(function (ar) {
var i = 0;
ar.forEach(function (element) {
td[i].textContent = element;
i++;
});
var clone = document.importNode(t.content, true);
tb[0].appendChild(clone);
});
var z2=document.querySelector('#z2');
z2.style.visibility='initial';
var z1=document.querySelector('#z1');
z1.style.visibility='collapse';
}
}
нужно ее транспонировать, все на чистом js. Помогите кодом, вузовская лаба