According to rugby law 19.8, here are a few things we need prior to taking the lineout:
- Both teams have same number of players contesting the lineout, who must be in a single straight line
- Both team contestants must be between the 5m and 15m line from the touch line
- Team lines must be 1m apart and the throw must be made straight in that 1m channel
According to rugby law 19.10:
- The jumpers can only jump once the ball is thrown
Now, they move back and forth because they have combinations. Playing at my club, the last number of a lineout call gives a combination. For example "Tequila 6 6 8" means it's combination 8 and players have rehearsed that in training.
They would know for example that number 8 means short lineout, therefore a jumper will jump close to the 5m line.
If the number was 5 from the call "2 Echo 5" for instance, the throw would be to the jumper close to the 15 meter line, etc...
You can have as many combinations as you want. When you have a lineout, you need the opposition not to know what you are about to do, hence trying to lure the opposition into believing you are going to throw at the 15m etc when you are going to end up throwing at the 5m line, by moving back and forth, and having weird calls.
As an external note though, everything that you are allowed to do in rugby, or not allowed to do in rugby is described in the rugby laws available online at http://laws.worldrugby.org/.