Question : What is the most effeicient way to get a user radio button selection with the GroupName attribute?

Hello,

I am designing a form and found that I had to use individual radio buttons rather than a radiobutton list to get user's feedback.  

I have multiple questions with multiple choices that use radio button controls for the selection. The radiobuttons have the proper group attribute.  What is the best way to return the selected radio value within the group?

I understand that I can use case statements or condition statements but because I have multiple questions I want to avoid the tedious programming and hoping there is a simple single line solution or a universal function that I can create in order to return the value.

As a followup what is the best way to validate these questions to ensure the user has made a selection in each question.

Thank you.

Answer : What is the most effeicient way to get a user radio button selection with the GroupName attribute?

You'll need to rely on javascript to check it client side.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
// replace myform and mygroup with your form and group names
var val = 0;

for( i = 0; i < document.myform.mygroup.length; i++ )
{
if( document.myform.mygroup[i].checked == true ) {
val = document.myform.mygroup[i].value;
break;
}
}
alert( "val = " + val );
Random Solutions  
 
programming4us programming4us