简体   繁体   English

使用JavaScript取消选中后,单选按钮列表选中的事件未触发

[英]radio button list checked event not firing after unchecked using javascript

I have a checkmark that when the user clicked on it if it's checked then a radiobuttonlist is visible. 我有一个复选标记,当用户单击它时(如果已选中),则可见单选按钮列表。 When the checkmark is unchecked the radiobuttonlist is not visible. 取消选中复选标记时,单选按钮列表不可见。 What I want to do is, when the checkmark gets unchecked if any item of the radiobuttonlist is checked I want to uncheck it, so if the user set the checkmark to checked again I want the radiobuttonlist to be visible but with all the items unchecked. 我想做的是,如果未选中单选按钮列表中的任何一项,则选中该复选框时,我要取消选中它,因此,如果用户再次将选中标记设置为选中状态,我希望单选按钮列表可见,但所有项目均未选中。

This is wat I did using JavaScript: 这是我使用JavaScript所做的事情:

elementRef = document.getElementById('<%= rowFlightClass.ClientID %>');
            clearList(elementRef)
function clearList(elementRef) {
        var inputElementArray = elementRef.getElementsByTagName('input');
        for (var i = 0; i < inputElementArray.length; i++) {
            var inputElement = inputElementArray[i];
            inputElement.checked = false;   

        }

}

but the radio buttons are not completely cleared, they are checked in memory, it seems. 但是单选按钮似乎没有完全清除,而是在内存中检查了它们。

With this code it looks like they are cleared but if you click on the previously selected radiobutton selected it's not firing the selectedindexchange event. 使用此代码,它们似乎已清除,但是如果您单击先前选择的单选按钮,则不会触发selectedindexchange事件。

You can get the checked and unchecked example from the following link- if it can help you. 您可以从以下链接获取已检查和未检查的示例(如果有帮助的话)。

http://www.aoiblog.com/checked-and-unchecked-the-radio-option-using-java-script/ http://www.aoiblog.com/checked-and-unchecked-the-radio-option-using-java-script/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM