/    Sign up×
Community /Pin to ProfileBookmark

arrayToDataTable

Hi everyone!I I will be very grateful if somebody can help
This part of code works.i am getting what i need. I can alert numbers from table column
1
2
3
4

[code]

var table2 = document.getElementById(‘tableMain’);
for (var i = 0; i < table2.rows.length; i++) {

var row2 = “”;

for (var j = 0; j < table2.rows[i].cells.length; j++) {

row2 += table2.rows[i].cells[j].innerHTML;

}

alert(row2);
// hire i get a numbers for example
/*
1
2
3
4
*/
}

[/code]

When i try to do like this, i get only last number. Number 4

[code]

var data1 = google.visualization.arrayToDataTable([
[‘Time’, ‘kWh’],
[row2, options1], // hire i get only last number and that is 4 but i need 1 2 3 4

]);

[/code]

In this block no problem. I can graph array if i type
[‘1 2 3 4’, 10000],
[‘5 6 7 8’, 20000],

[code]
var data1 = google.visualization.arrayToDataTable([
[‘Time’, ‘kWh’],
[‘1 2 3 4’, 10000],
[‘5 6 7 8’, 20000],

]);
var chart = new google.visualization.AreaChart(document.getElementById(‘chart_div’));
chart.draw(data1, options1);

[/code]

“option1” will act same only with different numbers wen i get this “row2” done.
This is only example but “row2” in reality contains very long list of numbers and i can only get a last one
Thank you for any help.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Ahmo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...