A cramp is an unpleasant sensation caused by contraction, usually of a muscle. It can be caused by cold or overexertion. Illness or poisoning can also cause cramps, particularly in the stomach, which is referred to as colic if it fits particular characteristics.
Menstruation also is highly likely to cause cramps of varying severity in the abdomen. Most of this is attributable to the passing of coagulated blood through the cervix. Menstrual cramps can be treated with ibuprofen, stretching exercises or the application of heat through such means as warm baths or heating pads. Menstrual cramps that do not respond to self-treatment can be a symptom of endometriosis or other health problems. A woman experiencing severe cramps should consult a gynecologist.
Electrolyte disturbance may cause cramping and tetany of muscles, particularly hypokalemia (a lack of potassium) and hypocalcemia (a lack of calcium).
There are two basic causes of cramping. One is inadequate oxygenation of muscle, and the other is lack of water or salt. Cramps from poor oxygenation can be improved by rapid deep breathing, and stretching the muscle. Cramps from lack of salt and water can be treated by stretching the muscle, drinking water and eating salty food (or drinking salty water). Pounding on the muscle can increase soreness.
Muscle cramps can be treated by applying a soft massage on the cramped muscle, streching the muscle and applying heat or cold. Heat improves superficial blood circulation and makes muscles more flexible, so some people find that heat is more soothing for muscle cramps than applying ice.
What happens in a cramp is that lactic acid builds up because of normal anaerobic muscle metabolism. When the muscle burns sugar without enough oxygen, it makes lactic acid. The lactic acid finally becomes concentrated enough to trigger the contraction of the muscle. When the muscle lacks salt, the nerves firing the muscle are unable to recharge properly, causing a similar effect.
Nocturnal leg cramps are involuntary muscle contractions that occur in the calves, soles of the feet or other muscles in the body during the night or (less commonly) while resting. The duration of nocturnal leg cramps is highly variable with cramps sometimes only lasting a few seconds and other times several minutes. Soreness in the muscles may remain for some time after the cramp ends. These cramps are more common in older populations but may happen to anyone.
Nocturnal leg cramps should not be confused with restless legs syndrome, a crawling sensation that is relieved by walking or moving around. Although uncomfortable, restless legs syndrome typically does not involve cramping or pain.
(extracted from wikipedia.com)
from my recollection of A level biology, the salt in question is potassium ions.