Here is an article worth reading on this topic. Click on this link to read the entire article or read an excerpt below.
…
Ultimately, doctors suspect the different physical triggers cause the same thing. Key minerals — sodium, potassium and calcium — all play a role in causing muscles to contract. When the levels of one or more of the minerals are depleted or changed, say, from lack of hydrating or from excessive sweating, muscle contraction can go awry.
…
Soothing the Spasms
Clearly, no fail-safe cure for charley horses exists, but doctors have a slew of tips to keep the spasms at bay: drinking plenty of water, eating enough potassium, and stretching before and after exercise is supposed to help avoid nighttime cramps.
When you get a charley horse, massages, stretching, warm baths, and ice are all generally recommended (although none are scientifically proven to work). Those who want relief in pill form can try vitamin B12 supplements.
The more risky treatments are muscle relaxers, anti-seizure medicine, dopamine, and the old school tonic, quinine. Quinine was regularly used as treatment for cramps until the FDA warned against its dangerous cardiac side effects.