Click here to Skip to main content
15,885,129 members
Please Sign up or sign in to vote.
1.73/5 (4 votes)
See more:
there is 60 question and each question has 5 answers so I use radiobutton list item but
how can count selected radiobuttonlists items

1 first question 1 2 3 4 5 answer(any good perfect etc.)
(radiobuttonlist1)

2 second question 1 2 3 4 5 answer
(radiobuttonlist2)

how to count radiobuttonlist1,radiobuttonlist2,...... which answer clicked


because in this survey at least 48 question must be clicked


I searched a lot of time I didnt find anything
Posted
Comments
Member-2338430 20-Feb-12 9:24am    
pleaseee
The Doer 20-Feb-12 23:01pm    
do u want total number of radio button checked among all 60*5 radio buttons??

Here is the code for your problem:-

function Checkform() {
    var result = true;
    $('.rbl').each(function() {
        var checked = $(this).find('input:radio:checked');
        if (checked.length == 0) {
            result = false;
            return;
        }
    });
    return result;
}

OR
$('input:radio').each(function() {
  if($(this).is(':checked')) {
    // You have a checked radio button here...
  }
  else {
    // Or an unchecked one here...
  }
});

OR
You can also loop through all the checked radio buttons like this, if you prefer:
$('input:radio:checked').each(function() {
   // Iterate through all checked radio buttons
});



These links will also be useful:-

http://www.reddybrek.com/post/Loop-through-all-radio-buttons-in-your-form-using-C.aspx[^]

http://www.randomsnippets.com/2008/05/15/how-to-loop-through-checkboxes-or-radio-button-groups-via-javascript/[^]

Update
Please try this :-

http://weblogs.asp.net/gurusarkar/archive/2010/10/14/get-radiobuttonlist-selectedvalue-in-javascript.aspx[^]

http://weblogs.asp.net/gurusarkar/archive/2010/10/14/get-radiobuttonlist-selectedvalue-in-javascript.aspx[^]

Thanks
 
Share this answer
 
v5
Comments
Member-2338430 20-Feb-12 6:37am    
I didnt use radio button I used radiobuttonlist item
Member-2338430 20-Feb-12 6:48am    
for (int i = 1; i <= 5; i++)
{
foreach (ListItem item in rbl[i].Items)
{
if (item.Selected)
{

count = count + 1;
Label1.Text = count.ToString();
}
}
}
howto do thatfirt radiobuttonlist
second radiobuttonlist
I want to navigate to radiobuttonlists
Varun Sareen 20-Feb-12 22:48pm    
Dear Friend, I have updated my solution. Please check
use 12 variables each variable name point to the radiobuttonlist
and value of each variable holding the answer
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900