const queryIfSelector = f => x =>
f(typeof x === 'string' ? document.querySelector(x) : x);
const getTableData = queryIfSelector(table =>
Array.from(table.querySelectorAll('tbody tr'), tr =>
Object.fromEntries(Array.from(tr.querySelectorAll('td'), td => [
td.getAttribute('data-name'),
td.querySelector('input').value,
]))
)
);
// или
const getTableData = queryIfSelector(table =>
Array.prototype.flatMap.call(table.tBodies, tbody =>
Array.prototype.map.call(tbody.rows, tr =>
Array.prototype.reduce.call(tr.cells, (acc, td) => (
acc[td.dataset.name] = td.firstElementChild.value,
acc
), {})
)
)
);
// или
const getTableData = queryIfSelector(table => {
const result = [];
const numHeadRows = table.querySelectorAll('thead tr').length;
for (const input of table.querySelectorAll('tbody input')) {
const td = input.closest('td');
const i = td.parentNode.rowIndex - numHeadRows;
const item = result[i] = result[i] || {};
item[td.attributes['data-name'].value] = input.value;
}
return result;
});
const data1 = getTableData('#table1');
const data2 = getTableData(document.querySelector('#table2'));
cell.textContent
cell.children[0].value
<hmtl>
<style>
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
text-align: center;
}
</style>
<body>
<div id="app"></div>
<table>
<tr data-new="1" data-id="1">
<td data-name="cell_11"><input type="text" value="11"></td>
<td data-name="cell_12"><input type="text" value="12"></td>
</tr>
<tr data-new="2" data-id="2">
<td data-name="cell_21"><input type="text" value="21"></td>
<td data-name="cell_22"><input type="text" value="22"></td>
</tr>
</table>
<script>
var x = {};
[].forEach.call(document.querySelectorAll("tr"), function(el) {
if (+el.getAttribute("data-new") >= 0) {
let inn = (x[el.getAttribute("data-id")] = {});
[].forEach.call(el.children, function(cell) {
inn[cell.getAttribute("data-name")] = cell.children[0].value;
});
}
});
var dataJSON = JSON.stringify(x)
document.querySelector("#app").innerHTML = dataJSON;
</script>
</body>
</hmtl>
cell.getElementsByTagName("input")[0].value
if ($limit && ceil($product_total / $limit) > $page) {
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page + 1), true), 'next');
}
if ($limit && ceil($product_total / $limit) < $page) {
$url = '';
if (isset($this->request->get['path'])) {
$url .= '&path=' . $this->request->get['path'];
}
if (isset($this->request->get['filter'])) {
$url .= '&filter=' . $this->request->get['filter'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_error'),
'href' => $this->url->link('product/category', $url)
);
$this->document->setTitle($this->language->get('text_error'));
$data['heading_title'] = $this->language->get('text_error');
$data['text_error'] = $this->language->get('text_error');
$data['button_continue'] = $this->language->get('button_continue');
$data['continue'] = $this->url->link('common/home');
$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('error/not_found', $data));
}
$start = '20:55';
$end = '00:05';
$float_start = floatval(str_replace(':', '.', $start));
$float_end = floatval(str_replace(':', '.', $end));
if ($float_start < $float_end) {
$date1 = new DateTime("2018-12-16 " . $start . ":00");
$date2 = new DateTime("2018-12-16 " . $end . ":00");
$interval = $date1->diff($date2);
} else {
$date1 = new DateTime("2018-12-16 " . $start . ":00");
$date2 = new DateTime("2018-12-17 " . $end . ":00");
$interval = $date1->diff($date2);
}
echo $interval->format('%H:%I');
<input type='checkbox' id='taxi' onchange="checkk(this);"/>
<input type='checkbox' id='ucheb' onchange="checkk(this);"/>
<script>
function checkk(elem) {
var id = elem.id;
if(id=='taxi') {
$('#ucheb').removeAttr("checked");
}
if(id=='ucheb') {
$('#taxi').removeAttr("checked");
}
}
</script>