I've retrieved values from a table, originating from a single column, that I end up storing in an array; but all the data is stored in a single index, and I haven't succeeded in splitting the array with .split.
Step 1 -- I target body and tr.
var stuff = document.getElementById('pricetable').querySelectorAll('tbody tr');
Step 2 -- I initiate a for-loop:
for (var i = 0; i < rows.length-1; i++) {
var rows2 = Array.prototype.slice.call(stuff)[i].querySelectorAll('td')[3];}
rows2 will now print a string that looks like this:
<td>2400</td>
<td>1900</td>
<td>9790</td>
<td>1098</td>
<td>1289</td>
<td>3284</td>
I think my problem starts here, since I don't know how to make it into an array and have each of these values stored its own index.
Step 3 -- To retrieve only the text, I create a new variable:
var my_list = rows2.textContent;
Step 4 -- I then attempt to split the array:
var price_list = my_list.split(','));
Although price_list is an array (I verified), all values remain in price_list[0]. It prints like this:
["2400"]
["1900"]
["9790"]
["1098"]
["1289"]
["3284"]
If split won't do the trick in this case, do I need to loop through those values? If so, how? Or should I have taken a different course of action? The research that I've done explains how split works with predefined strings that aren't retrieved from the DOM.