this is my Javascript which behaves like an Radiobutton. where user can select only 1 option at a time (ex: if he select item1 and selects item2 then item1 gets deselected, as he as selected item2 if he clicks again on item2 it gets deselected.) which make user either select any one item or deselect the selected item to
this condition works fine
issue
i have an button in page once user clicks that button again if user selects any item[eg item1 is selected before clicking on the button. then after clicking the button. and now if we selected any item in checkboxlist the initially selected item1 is not getting deselected when i am selecting another item in check boxlist
below is my code
var objChkd;
function HandleOnCheck()
{
var chkLst = document.getElementById('CheckBoxList1');
if(objChkd && objChkd.checked)
objChkd.checked=false;objChkd = event.srcElement;
}
and register the client event to the 'CheckBoxList1' at the Page_load as
CheckBoxList1.Attributes.Add("onclick","return HandleOnCheck()");
in .cs file i don't want to do this CheckBoxList1.clearSelection();
any help would be great
thank you
objChkddeclared? Why are you definingchkLstin your function and then not using it? And most of all, why aren't you using actual radio buttons?