Question: How to Unselect the Chack Box Lists other that what i selected now. These check Box Lists are Items os a DataList. I want to to it in Client side.
Answer:
In code behind:
protected void dlQuestion_PreRender(object sender, EventArgs e)
{
foreach (DataListItem dlItem in dlQuestion.Items)
{
string RadiobuttonListIdsWithoutCurrentRBL = string.Empty;
RadioButtonList rdblChapterQuestions = (RadioButtonList)dlItem.FindControl("rdblChapterQuestions");
RadiobuttonListIdsWithoutCurrentRBL = RadiobuttonListIds.Replace(rdblChapterQuestions.ClientID + ",", "");
RadiobuttonListIdsWithoutCurrentRBL = RadiobuttonListIdsWithoutCurrentRBL + rdblChapterQuestions.ClientID;
foreach (ListItem li in rdblChapterQuestions.Items)
{
//javascript:RemoveRadioButtonSelect(" + RadiobuttonListIdsWithoutCurrentRBL + ")
li.Attributes.Add("onclick", "RemoveRadioButtonSelect('" + RadiobuttonListIdsWithoutCurrentRBL + "');");
}
}
}
//li.Attributes.Add("onclick", "RemoveRadioButtonSelect(" + RadiobuttonListIdsWithoutCurrentRBL + ")");
//RadiobuttonListIdsWithoutCurrentRBL => string will give all radiobutton ids to be unchecked.
In mark up page:
<script language="javascript" type="text/javascript">
function RemoveRadioButtonSelect() {
//RemoveRadioButtonSelect.arguments will give all the arguments passing through this RemoveRadioButtonSelect()
var argv = RemoveRadioButtonSelect.arguments;
var argc = argv.length;
for (var i = 0; i < argc; i++) {
// will get the RadioButtonList Ids One by One
var radioButtonListId = document.getElementById(argv[i].id);
if (radioButtonListId != null) {
// will get the input tags of the RBL.
var objListItem = radioButtonListId.getElementsByTagName('input');
for (var itemCount = 0; itemCount < objListItem.length; itemCount++) {
//Looping through the all input tags of RBL
objListItem[itemCount].checked = false;
}
}
}
}
</script>
-------------*********************************--------------