Radio Button functionality in a Grid/Repeater/DataList controls

Lakhangarg
Posted by Lakhangarg under C# category on | Views : 3474
To select one option in a Grid/Repeater/DataList controls
Pass the Container Control's ID and Radio Button ID mentioned in grid.

function SelectOneOption(ctlTargetControl,ctlID)
{
var TargetControl = document.getElementById(ctlTargetControl);
var checkCount=0;
var Inputs = TargetControl.getElementsByTagName("input");
for(var n = 0; n < Inputs.length; ++n)
{
if(Inputs[n].type == 'radio' && Inputs[n].id == ctlID)
{
if(Inputs[n].checked)
checkCount=checkCount+1;

if(checkCount>1)
retrun false;
}
}
return true;
}

Comments or Responses

Login to post response