Java script for radio button values
Hi, I am creating a questionnaire using radio buttons, but I can't seem to get the script to work (the script below works perfectly for a checkbox button), the client wants to change the checklist to a radio button, I tried changing the script below from "checklist" to "radiobutton"but this didn't seem to work. In the pdf I have made all the field names etc exactly the same except it is now a radio button not a check box. Is it possible to get some help with the script below? Thank you.
{
var temp = 0;
for(var i = 0; i < this.numFields; i++)
{
var name = this.getNthFieldName(i);
var field = this.getField(name);
if (field.type == "checklist" && field.value != "Off")
{
temp += field.value;
}
}
this.getField("Total Score").value = temp;
var f = this.getField("Risk");
if (temp>=5 && temp <=24){
var g = this.getField(f.name+".0");
g.defaultIsChecked(0,true);
}
if (temp>=25 && temp <=39){
var g = this.getField(f.name+".1");
g.defaultIsChecked(0,true);
}
if (temp>=40 && temp <=54){
var g = this.getField(f.name+".2");
g.defaultIsChecked(0,true);
}
if (temp>=55 && temp <=64){
var g = this.getField(f.name+".3");
g.defaultIsChecked(0,true);
}
if (temp>=65 && temp <=75){
var g = this.getField(f.name+".4");
g.defaultIsChecked(0,true);
}
this.resetForm(["Risk"]);
}
