Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio button array from survey loop

Status
Not open for further replies.

envisiondesign

Programmer
Jan 25, 2005
9
US
I am starting to learn C# along with ASP.NET. I am a PHP programmer trying to stretch out.

I have a survey that is 10 questions with 5 possible answers that are radio buttons. I am using this to limit the users possible choice to one per question.

<asp:RadioButton id="RadioButton1" runat="server" value="0" groupname="q1"></asp:RadioButton>
<asp:RadioButton id="RadioButton2" runat="server" value="0" groupname="q1"></asp:RadioButton>
<asp:RadioButton id="RadioButton3" runat="server" value="0" groupname="q1"></asp:RadioButton>
<asp:RadioButton id="RadioButton4" runat="server" value="0" groupname="q1"></asp:RadioButton>
<asp:RadioButton id="RadioButton5" runat="server" value="0" groupname="q1"></asp:RadioButton>

And there are obviously 10 separate Group Names.

My question is how do I process this and do I need to change the radiobutton syntax to...

<asp:RadioButton id="RadioButton[1]" runat="server" value="0" groupname="q1"></asp:RadioButton>

With PHP I would do this

$q = $_POST['radiobutton'];
$score = array_sum($q);

Any help is great.

If you choose not to decide you still have made a choice; choose life.
 
Oops the value of each one increments from 0-4

If you choose not to decide you still have made a choice; choose life.
 
Use a RadioButtonList and loop through each group for the selected value.
Code:
foreach(ListItem li in yourRBList)
{
  if(li.Selected == true)
     {
       Response.Write("<br/>Text: " + li.Text + " - Value: " + li.Value)
     }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top