varuserAnswer=0;
//累计分数
functiongetUserAnswer(radioGroupName) {
varrg=document.getElementsByName(radioGroupName);
for(vari=0;i
if(rg[i].checked==true)
userAnswer+=parseInt(rg[i].value);
}
}
//检查是否都选了
functioncheckAllAnswer() {
varresult;
varti= [20];
vare;
for(e=1;e<21;e++) {
varname='RadioGroup'+e;
varrg=document.getElementsByName(name);
result=0;
for(vari=0;i
if(rg[i].checked==true)
result+=parseInt(rg[i].value);
}
if(result==0) {
ti[e] =0;
}else{
ti[e] =result;
}
}
//设置红星的可见属性
for(varj=1;j<=20;j++) {
if(ti[j] ==0) {
document.getElementById(j+"").style.visibility="visible";
}else{
document.getElementById(j+"").style.visibility="hidden";
}
}
//没有选的返回false
for(varj=1;j<=20;j++) {
if(ti[j] ==0)return false;
}
return true;
}
//提交,计算得分 并且分级等级
functionshowResult() {
userAnswer=0;
if(checkAllAnswer() ==true) {
for(vari=1;i<=20;i++){
getUserAnswer("RadioGroup"+i);
}
if(userAnswer>=20&&userAnswer<=36)
alert("分数:"+userAnswer+",优质客户!");
if(userAnswer>=37&&userAnswer<=72)
alert("分数:"+userAnswer+",可安抚客户!");
if(userAnswer>=73&&userAnswer<=100)
alert("分数:"+userAnswer+",高风险客户!");
}else{
alert("请做完再提交!");
}
}
//重置之后 红星隐藏
functionset() {
for(vari=1;i<=20;i++) {
document.getElementById(i+"").style.visibility="hidden";
}
}