Array push problem with extra comma showing

Array push problem with extra comma showing

Hello,

I am having a problem with a comma showing at the start of my sortable result.


My html:


  1. <table class="table">
    <thead>
    <tr>
    <th>id</th>
    <th>Category</th>
    <th>Activated?</th>
    </tr>
    </thead>
    <tbody>
    <tr id=18>
    <td>18</td>
    <td>Cardboard</td>
    <td>1</td>
    <td><a href='' class='btn btn-warningrole='button'>Edit</a></td>
    </tr>
    <tr id=16>
    <td>16</td>
    <td>Equipment to lease</td>
    <td>1</td>
    <td><a href='' class='btn btn-warningrole='button'>Edit</a></td>
    </tr>
    <tr id=17>
    <td>17</td>
    <td>Ovens</td>
    <td>1</td>
    <td><a href='' class='btn btn-warningrole='button'>Edit</a></td>
    </tr></tbody>
    </table>







The jquery:

  1.     <script>

  2.     $(function() {
  3.     $('tbody').sortable({items: 'tr'});
  4.     });


  5.     function saveOrder() {
  6.     var selectedLanguage = new Array();
  7.     $('tr').each(function() {
  8.     selectedLanguage.push($(this).attr("id"));
  9.     });

  10.     document.getElementById("row_order").value = selectedLanguage;
  11. </script>
Now here is the result I am getting:

array(2) { ["row_order"]=> string(9) ",18,16,17" ["sort"]=> string(10) "Save Order" }

I am getting an extra comma just before the number 18, I cannot work out why, any idea please?


Thank you.