I have this html form which has a number of items in which you can change the order - from 1 to any number
The order should always be 1,2,3,4,5,6,7, etc..but I am having a problem figuring out how to maintain that data when the order is being edited.
See the example below..the first line is the original data, the second line is the new data
1 -> 2
2 -> 1
3 -> 3
4 -> 5
5 -> 4
Above, it is pretty simple, I can just re-order based on the input, however it gets more difficult if something else is entered.
1 -> 2
2 -> 1
3 -> 3
4 -> 5
5 -> 1
Above, I need to fix it so either the original 2, or 5 is now 1, then the next is 2, and then make sure there is a 3,4, and 5.
Now it gets harder..
1 -> 10
2 -> 4
3 -> 3
4 -> 5
5 -> 5
This would have to be again, fixed so that 3 now becomes 1, 2 becomes 2, 4 or 5 becomes 3, and 1 becomes 5.
This is probably getting confusing...anyway, unfortunately I can't display any type of error message to the user, I just have to make sure the order stays starting at 1, and is sequential, with no duplicates, all the way to however many items are in the list. I've spent about an hour trying different methods to get this to work but haven't been successful. Anyone have any ideas?
The order should always be 1,2,3,4,5,6,7, etc..but I am having a problem figuring out how to maintain that data when the order is being edited.
See the example below..the first line is the original data, the second line is the new data
1 -> 2
2 -> 1
3 -> 3
4 -> 5
5 -> 4
Above, it is pretty simple, I can just re-order based on the input, however it gets more difficult if something else is entered.
1 -> 2
2 -> 1
3 -> 3
4 -> 5
5 -> 1
Above, I need to fix it so either the original 2, or 5 is now 1, then the next is 2, and then make sure there is a 3,4, and 5.
Now it gets harder..
1 -> 10
2 -> 4
3 -> 3
4 -> 5
5 -> 5
This would have to be again, fixed so that 3 now becomes 1, 2 becomes 2, 4 or 5 becomes 3, and 1 becomes 5.
This is probably getting confusing...anyway, unfortunately I can't display any type of error message to the user, I just have to make sure the order stays starting at 1, and is sequential, with no duplicates, all the way to however many items are in the list. I've spent about an hour trying different methods to get this to work but haven't been successful. Anyone have any ideas?