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:
-
<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-warning' role='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-warning' role='button'>Edit</a></td> </tr> <tr id=17> <td>17</td> <td>Ovens</td> <td>1</td> <td><a href='' class='btn btn-warning' role='button'>Edit</a></td> </tr></tbody> |
|
</table> |
The jquery:
- <script>
- $(function() {
- $('tbody').sortable({items: 'tr'});
- });
- function saveOrder() {
- var selectedLanguage = new Array();
- $('tr').each(function() {
- selectedLanguage.push($(this).attr("id"));
- });
- document.getElementById("row_order").value = selectedLanguage;
- </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.