The best way to cope with muscle cramps and spasms is to prevent them. There are a number of things you can do to keep yourself from experiencing pain. First, always stay properly hydrated. It is important to replace the fluids that you lose during exercise and physically exerting work. Always drink water at regular intervals, even before you are thirsty. Drink more than your thirst requires and drink a sports beverage containing electrolytes if you are working in the heat or are sweating for more than an hour. It’s a good idea to avoid soda and coffee as well. Drinking these beverages will dehydrate you faster than drinking nothing. If you do have a soda or a cup of coffee, you should try to drink twice the amount you drank in water. It’s also important to eat fruits that are high in potassium, such as bananas, and to take a daily multi-vitamin.
References
http://www.spinesource.com/caring/first-aid.html
http://www.doctorsexercise.com/journal/cramp.htm
http://sportsmedicine.about.com/cs/leg_injuries/a/leg8.htm