0
I am wanting to pass a list that are added on a page and clicking the remove button from that list(line) go to another page(final.html).
function adicionaLinha(idTabela) {
var tabela = document.getElementById(idTabela);
var numeroLinhas = tabela.rows.length;
var linha = tabela.insertRow(numeroLinhas);
var celula1 = linha.insertCell(0);
var celula2 = linha.insertCell(1);
var celula3 = linha.insertCell(2);
celula1.innerHTML = 'Quarto '+ Math.floor((Math.random() * 10) + 1);
celula2.innerHTML = Math.floor((Math.random() * 10) + 1);
celula3.innerHTML = "<button onclick='removeLinha(this)'>Remover</button>";
}
// funcao remove uma linha da tabela
function removeLinha(linha) {
var i=linha.parentNode.parentNode.rowIndex;
document.getElementById('tbl').deleteRow(i);
}
<!DOCTYPE html>
<html>
<head>
<title>Buttler</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans|Source+Sans+Pro" rel="stylesheet">
</head>
<body>
<header class="main-container">
<div>
<a href="index.html"><img src="img/hotel.jpeg" alt="hotel"></a>
</div>
<aside class="menu">
<ul>
<li><a href="index.html">PEDIDOS EM ABERTO</a></li>
<li><a href="pages/final.html">PEDIDOS FINALIZADOS</a></li>
</ul>
</aside>
</header>
<section class="header-title">
<div class="main-title">
<h3>Page aberta</h3>
</div>
</section>
<section class="content">
<button onclick="adicionaLinha('tbl')">Adicionar</button>
<table id="tbl" class="tbl">
<tr>
<td>N° DO QUARTO</td>
<td>PEDIDO</td>
<td>STATUS</td>
</tr>
</table>
</section>
<script src="main.js"></script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Buttler</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="../css/style.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans|Source+Sans+Pro" rel="stylesheet">
</head>
<body>
<header class="main-container">
<div>
<a href="../index.html"><img src="../img/hotel.jpeg" alt="hotel"></a>
</div>
<aside class="menu">
<ul>
<li><a href="../index.html">PEDIDOS EM ABERTO</a></li>
<li><a href="final.html">PEDIDOS FINALIZADOS</a></li>
</ul>
</aside>
</header>
<section class="header-title">
<div class="main-title">
<h3>Page fechada</h3>
</div>
</section>
<section class="content">
<table id="tbl" class="tbl">
<tr>
<td>N° DO QUARTO</td>
<td>PEDIDO</td>
<td>STATUS</td>
</tr>
</table>
</section>
<script src="../main.js"></script>
</body>
</html>
These pages are being served by a server, or is it something static that you have on your machine?
– Andre