Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
Can we get the count of total radiobuttonlist items from .aspx page.
I have to call a javascript function onclientclick of a button and i want to loop through the total number of radiobuttonlist items.
So can anyone tell me that can we get it from .aspx page. Because in my scenario i can not use code behind for this.

Thanks in advance.
Please help.
Please tell me is it possible or not?
Posted
Updated 28-Nov-11 19:28pm
v5

you can use javascript function something like this..

JavaScript
function yourfunction(radioBtnListID)
{
    var rdbtnlist = document.getElementId(radioBtnListID);
    
    for(var i=0;i<rdbtnlist.options.length-1;i++)>
    {
         if (rdbtnlist.options[i].checked==true)
         {
             var name = rdbtnlist.options[i].name;
             alert("item " + name + " is checked");
             // or add your code
         }
         else
         {
            var name = rdbtnlist.options[i].name;
            alert("item " + name + " is checked");
            // or add your code

         }
    } 
}


hope this helps...
 
Share this answer
 
Comments
RaisKazi 29-Nov-11 5:10am    
My 5.
I just created a javascript function as mentioned by Karthik Harve and found the total number of rows generated dynamically as below: -



function ClearRBL() {
var rblLen = document.getElementById('rblWorkerList');
for (i = 0; i < rblLen.rows.length; i++) {
document.getElementById('rblWorkerList_' + [i]).checked = false;
}
}


It's working on both Mozila and IE.


Thanks alot to all who tried to help and special thanks to Karthik Harve.
 
Share this answer
 
I just created a javascript function as mentioned by Karthik Harve and found the total number of rows generated dynamically as below: -



function ClearRBL() {
var rblLen = document.getElementById('rblWorkerList');
for (i = 0; i < rblLen.rows.length; i++) {
document.getElementById('rblWorkerList_' + [i]).checked = false;
}
}


It's working on both Mozila and IE.


Thanks alot to all who tried to help and special thanks to Karthik Harve.
 
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