Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Alex Isay

Coletando dados de uma tabela HTML usando Java Script

Recommended Posts

Pessoal bom dia,

 

Estou com um projetinho de criar estatísticas de jogos , e preciso a princípio coletar os valores de uma tabela HTML usando Java Script e armazenála em um BD Mysql via PHP .

 

O problema é que não sei como coletar estes valores da tabela !!

 

Abaixo vou postar o código HTML.

 

<html>
<head>
<title>Resultado da Mega-sena</title>
<STYLE>
TD {
FONT-FAMILY: Arial;
FONT-SIZE: 10pt;
HEIGHT: 15pt;
TEXT-ALIGN: center
}
</STYLE>
</head>
<body>
<p><strong><big><big><font face="Arial" color="#004080">Resultado da Mega-sena</font></big></big></strong></p>
<p><img src="t2.gif">
</p>
<table border="0" cellspacing="1" cellpadding="0" width="1810">
<tr>
<th width="50"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Concurso</font></small></th>
<th width="100" height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Data Sorteio</font></small></th>
<th width="80"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">1ª Dezena</font></small></th>
<th width="80"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">2ª Dezena</font></small></th>
<th width="80"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">3ª Dezena</font></small></th>
<th width="80"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">4ª Dezena</font></small></th>
<th width="80"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">5ª Dezena</font></small></th>
<th width="80"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">6ª Dezena</font></small></th>
<th width="120"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Arrecadacao_Total</font></small></th>
<th width="95" height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Ganhadores_Sena</font></small></th>
<th width="120"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Rateio_Sena</font></small></th>
<th width="131" height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Ganhadores_Quina</font></small></th>
<th width="120"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Rateio_Quina</font></small></th>
<th width="131"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Ganhadores_Quadra</font></small></th>
<th width="120"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Rateio_Quadra</font></small></th>
<th width="70"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Acumulado</font></small></th>
<th width="120"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Valor_Acumulado</font></small></th>
<th width="120"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Estimativa_Prêmio</font></small></th>
<th width="120"  height="20" bgcolor="#7BA8D9"><small><font face="Arial" color="#FFFFFF">Acumulado_Mega_da_Virada</font></small></th>
</tr>
<tr>

<td>1</td>

<td>11/03/1996</td>

<td>41</td>

<td>05</td>

<td>04</td>

<td>52</td>

<td>30</td>

<td>33</td>

<td>0,00</td>

<td>0</td>

<td>0,00</td>

<td>17</td>

<td>39.158,92</td>

<td>2016</td>

<td>330,21</td>

<td>SIM</td>

<td>1.714.650,23</td>

<td>0,00</td>

<td>0,00</td>

</tr>

<tr bgcolor=#D9E6F4>

<td>2</td>

<td>18/03/1996</td>

<td>09</td>

<td>39</td>

<td>37</td>

<td>49</td>

<td>43</td>

<td>41</td>

<td>0,00</td>

<td>1</td>

<td>2.307.162,23</td>

<td>65</td>

<td>14.424,02</td>

<td>4488</td>

<td>208,91</td>

<td>NÃO</td>

<td>0,00</td>

<td>0,00</td>

<td>0,00</td>

</tr>
</table>
</body>
</html>

Por enquanto é só isso ai,

 

Eu preciso pegar estes valores dos <td>valorrrr</td> e jogar em um array ou uma variável qualquer para depois via json enviar para o MysQl.

 

Aguardo...

Compartilhar este post


Link para o post
Compartilhar em outros sites

exemplo:

alert( document.getElementsByTagName('td')[0].innerHTML );

faça um loop percorrendo todos os TDs que precisar, e vá lendo dessa forma que mostrei.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.