I have a basic table:
<table> <tr> <td class="priority-select"><select></select></td> </tr> <tr> <td class="priority-select"><select></select></td> </tr> <tr> <td class="priority-select"><select></select></td> </tr> <tr> <td class="priority-select"><select></select></td> </tr> </table> For each of these ".priority-select select" elements, I need to append option tags, with values of the indexes, and the current index with the selected attribute. Example:
<table> <tr> <td class="priority-select"> <select> <option value="1" selected>1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </td> </tr> ............. to n rows </table> I'm using this snippet to do that:
var $selects = $(".select"); var selCount = $selects.length; for(var i=1; i<=selCount; i++){ $selects.append("<option value='" + i + "'>" + i + "</option>"); }; I don't know how to begin the next part, which is updating the table rows based on the selection a user makes.
I.e. the user selects in the third row's select, the row is removed from the order, set as the first row, and then all the rows are reordered and reindexed so on the next selection the user will be able to change the order and get it right. This would be done after selecting the option and not having to submit anything else.
Any help would be appreciated.