Potrebujem vytvoriť jednu tabuľku a jeden graf. Keď kliknem na riadok v tabuľke, údaje z riadku sa zobrazia v grafe. Vedeli by ste mi poradiť / dať link, tutorial ? oceňujem každú radu.
Fórum › JavaScript, AJAX, jQuery
Zobrazenie hôdnot z riadku tabuľky v grafe

#1 userz21
Dohledej si, jak přistupovat k tabulce v JS. Stačí zkrátka table, anebo tbody v HTML5 vytáhnout skrz "document.getElementBy..." a následně přidat handler události click každému řádku, či click přidat přímo vytaženým elementům "tr". (onclick) Opět zcela základní znalost JS -> tedy nauč se obecně JS. No a pak již akoráte přeneseš data z řádku -> tr.cells -> stačí zase jen umět JS, což ti umožní každý tutoriál se základy. Na grafy jsou také snadno dostupné tutoriály. Vážně mne nenapadá nic lepšího, než abys počal s učením se JS.
Googlem si najdi js programy pro vytvareni grafu. Budou mit jiste podobne funkce. Jinak to tedy neni zas az takovy problem.
<table id=xxx>
<tr>
<td>A1</td>
<td>B1</td>
<td>C1</td>
</tr>
<tr>
<td>A2</td>
<td>B2</td>
<td>C2</td>
</tr>
</table>
<div id=yyy>
Graf
<span>bod A1</span>
<span>bod B1</span>
<span>bod C1</span>
<span>bod A2</span>
<span>bod B2</span>
<span>bod C2</span>
</div>
<script>
var tbl, gph, td, span, i;
tbl = document.getElementById('xxx');
gph = document.getElementById('yyy');
td = tbl.getElementsByTagName('TD');
span = gph.getElementsByTagName('SPAN');
for (i=0;i<td.length;i++)
{
td[i].onclick=function(){fff(this);}
td[i].id = 'x'+i
span[i].id = 'y'+i;
}
function fff(td_sel)
{
var i, id;
for (i=0;i<td.length;i++)
{
td[i].className=''; //.parentNode
span[i].className='';
}
td_sel.className='sel'; //.parentNode
id = 'y'+td_sel.id.substring(1);
span[id].className='sel';
}
</script>
<style>
td {background:#ddd;}
td.sel, span.sel {background:#f80;}
</style>
http://jsfiddle.net/su8LqLtk/

Přidej příspěvek
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
































Uživatelé prohlížející si toto vlákno
Podobná vlákna
Překopírování tabulky do druhé tabulky s doplněním hodnot — založil marpit
DOMDocument - zobrazenie td z tabuľky — založil Anonym54564546434
Funkcia PHP na zobrazenie všetkých dát z tabuľky — založil Lukáš
Vypsání unikátních hodnot z tabulky — založil polonium
Seznam hodnot ze sloupce tabulky — založil Stirling
Moderátoři diskuze