This is my first S.O. question so please be kind.
I have an array of year/month values that looks something like this
[["2012", "1"], ["2013", "3"], ["2013","4"], ["2013", "3"]]
Essentially I have a rails active record that when i am looping through my array if the year and month already exist I dont want to create a new row I want to put the data in one of my 4 columns in a previous existing row.
So the table might look like this
<table>
<tr>
<th>Month/Year</th>
<th>Sales</th>
<th>Tech Support</th>
<th>Management</th>
</tr>
<tr>
<td>Jan/12</td>
<td>10</td>
<td>%nbsp;</td>
<td> </td>
</tr>
<tr>
<td>Mar/13</td>
<td> </td>
<td>10</td>
<td> </td>
</tr>
<tr>
<td>Apr/13</td>
<td> </td>
<td>%nbsp;</td>
<td>10;</td>
</tr>
<tr>
<td>Mar/13</td>
<td>10</td>
<td>%nbsp;</td>
<td> </td>
</tr>
</table>
I have if statements that tell me if it's Sales, Tech Support, or Managment so that it knows which column to put it in, my issue.
Essentially what I want is that last row of Mar/13 to say "hey you already have a Mar/13 row, this value should go into one of it's columns (and the data is such that I will never repeat a column.)
Would I be better served by creating the table with ID's for the TD's in rails that match the year/month/column and then assigning the active record to a javascript array that uses those IDs to put the values in using the innerHTML or is there a smarter way to do this?
Essentially what I want is that last row of Mar/13 to say "hey you already have a Mar/13 row, this value should go into one of it's columns (and the data is such that I will never repeat a column.)do you mean should go into one of it's existing rows?