I have many functions for calculating some stats , and i need to recheck the value's every time but that is extra code and make's it harder to read , can i store the variable assignment in another function:
function MC () {
var check=document.getElementById('check').checked;
var ea=Number(document.form.ea.value),
ed=Number(document.form.ed.value),
pa=Number(document.form.pa.value),
pd=Number(document.form.pd.value);
var hpSum = 0,spSum=0,eaSum=0,edSum=0,pdSum=0,paSum=0;
if(check){
eaSum = ea + 11;
edSum = ed + 17;
pdSum = pd + 17;
paSum = pa + 11;
} else {
eaSum = ea - 11;
edSum = ed - 17;
pdSum = pd - 17;
paSum = pa - 11;
}
document.form.ea.value=eaSum;
document.form.ed.value=edSum;
document.form.pa.value=paSum;
document.form.pd.value=pdSum;
};
NOTE:I am speaking for the variables:ea,ed,pa,pd and sum variables.