用javascript清空radio button list的内容(use javascript to clear the radiobuttonlist)

时间:2022-06-18 17:20:56

上C#.NET代码:

function someAreaChanged(radioButtonList) {
            
            var vRbtid = document.getElementById('<%=someArea.ClientID%>');
            //get all radio
            var vRbtidList = vRbtid.getElementsByTagName("Input");
            var twork = document.getElementById('<%=twork_radio_button_list.ClientID%>');
            for (var i = 0; i < vRbtidList.length; i++) {
                if (vRbtidList[i].checked && i == 0) {
                    changeItemState(twork, true);
                }
                if (vRbtidList[i].checked && i == 1) {
                    changeItemState(twork, false);
                }
            }
        }

function changeItemState(radiobutton, disable) {
            var radiobuttonItems = radiobutton.getElementsByTagName('input');
            for (var itemIndex = 0; itemIndex < radiobuttonItems.length; itemIndex++) {
                if (disable == true && radiobuttonItems[itemIndex].checked) {
                    radiobuttonItems[itemIndex].checked = false;     //这行代码用来清空radio button list的选中内容
                }
                radiobuttonItems[itemIndex].disabled = disable;
            }
        }