I'm attempting to do something that is a bit out of my wheelhouse here, and I'm hoping primarily to be pointed in the right direction conceptually (of course, code never hurts).
In a cshtml page, I have n number of drop-down lists, each with the values 1, 2, 3... n. I don't want any drop-downs to ever contain the same value as another on the page. I am looking for a way to dynamically do this with Javascript.
Are there any clever ways to do this? I can think of a pretty ugly algorithm involving running through each drop-down every time one of the drop-down lists changes value, looking for any drop-down with the same value, and adding 1 to it (rolling over to 1 if we are at n). Then having to go through again, to change the next list we run across with the same value as the previous. Eventually, we would stop after n times through every list (Run-time O(n^2)). Even if there isn't a clever way of doing this, I can't imagine that is anywhere close to an optimal solution.
Any advice at all would be greatly appreciated. Thanks.