Ola pessoal estou com um problema fiz uma tabela dinâmica em javascript e estou querendo jogar os dados da tabela em array tentei usar json para isso mas quando clico no botão do evento não faz nada não sei se esta faltando algum plugin pois nunca havia trabalhado com json segue o código.
<!DOCTYPE html>
<html>
<head> <meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../css/bootstrap.css"/>
<script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script> <script
type="text/javascript" src="../js/jquery.validate.min.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<title> Controle de Material </title> <!-- Aqui esta o meu script para criar a tabela -->
<script LANGUAGE="JavaScript">
totals =0;
function adiciona(){
totals++
tbl = document.getElementById("tabelaPedido")
var novaLinha = tbl.insertRow(-1);
var novaCelula;
if(totals%2==0) cl = "#FFFFFF";
else cl = "##FFFFFF";
novaCelula = novaLinha.insertCell(0);
novaCelula.align = "left";
novaCelula.style.backgroundColor = cl;
novaCelula.innerHTML = document.getElementById('cprod').value;
totals;
novaCelula = novaLinha.insertCell(1);
novaCelula.align = "left";
novaCelula.style.backgroundColor = cl;
novaCelula.innerHTML = document.getElementById('cquant').value;
novaCelula2 = novaLinha.insertCell(2);
novaCelula.align = "left";
novaCelula.style.backgroundColor = cl;
var btnEl = document.createElement('input');
btnEl.setAttribute('type', 'button');
btnEl.setAttribute('class', 'btn');
btnEl.onclick = function () {deleteRow(this.parentNode.parentNode.rowIndex)};
btnEl.setAttribute('value', 'Delete');
novaCelula2.appendChild(btnEl);
}
//Função para excluir a linha
function deleteRow(i){
document.getElementById('tabelaBanco').deleteRow(i) }
function pedido(){
// Percorrer todas as linhas do corpo da tabela
$('#tabelaPedido tbody tr').each(function () {
// Recuperar todas as colunas da linha percorida
var colunas = $(this).children();
var pedidos = [];
// Criar objeto para armazenar os dados
var pedido = {
'produto': $(colunas[0]).text(), // valor da coluna Produto
'quantidade': $(colunas[1]).text() // Valor da coluna Quantidade
};
// Adicionar o objeto pedido no array
pedidos.push(pedido);
});
// listando os pedidos função teste
alert(pedidos);
alert("esta funcionando");
}
</script>
</head>
<body>
<table>
<tr>
<td><p> Produto: </p> </td>
<td> <p> Quantidade </p> </td>
</tr>
<tr>
<td> <input type="text" name="produto" id="cprod"> </td>
<td> <input type="text" name="quantidade" id="cquant"> </td>
<td> <input type='button' id='incluir' class="btn" value='Incluir Produto' onclick='adiciona()'/> </td>
</tr>
</table>
<table id='tabelaPedido' class="table table-hover" border='0' width='100%'>
<thead>
<tr style='background-color:#FBF6F7'>
<td class="produto"><strong>Produto</strong></td>
<td class="quantidade"><strong>Quantidade</strong></td>
<td><strong>Excluir</strong></td>
</tr>
</thead>
<tbody>
</tbody> </table>
<br/>
<!-- chamando a função para pegar os dados e imprimir na telana -->
<input class="btn" type = "submit" name = "but" value ="Confirmar Pedido" onclick='pedido()'/>
<br><br><br>
</form>
</body>
</html>