I have a list of radiobuttons that varies depending on the number of items that is stored in the database.
The user clicks the selected radio button and then clicks a 'get' button. I have a javascript that checks whether a radio is checked. It works fine if I have more than one radiobutton, but not if I have only one! Then 'intControlLength ' is undefined!
This is the script (I found some of this code here.):
function OpenQuestionnaire() {
var objFormField = document.form1.QuestRadioGroup;
var intControlLength = objFormField.length;
var bolSelected = false;
for (i=0;i<intControlLength;i++){
if(objFormField.checked){
bolSelected = true;
break;
}
}
if(! bolSelected){
alert("Please, choose a questionnaire."
return false;
}else {
return true;
}
}
Can someone help me on this?
Thanks
The user clicks the selected radio button and then clicks a 'get' button. I have a javascript that checks whether a radio is checked. It works fine if I have more than one radiobutton, but not if I have only one! Then 'intControlLength ' is undefined!
This is the script (I found some of this code here.):
function OpenQuestionnaire() {
var objFormField = document.form1.QuestRadioGroup;
var intControlLength = objFormField.length;
var bolSelected = false;
for (i=0;i<intControlLength;i++){
if(objFormField.checked){
bolSelected = true;
break;
}
}
if(! bolSelected){
alert("Please, choose a questionnaire."
return false;
}else {
return true;
}
}
Can someone help me on this?
Thanks