js 得到 radiobuttonlist和CheckBoxList 选中值

时间:2023-10-16 18:54:44
得到radiobuttonlist 选中值:
var CheckBoxList=document.all.optButtonList; 
            var objCheckBox,CheckValue="";
            for(i=0;i<CheckBoxList.rows.length;i++)   
            {   
                 objCheckBox   =    document.getElementById('optButtonList'+ "_"   +    i); 
                  if(objCheckBox.checked == true)
                   {
                                              CheckValue = objCheckBox.value;   
                   }
            }
            if(CheckValue!="")
            {
                alert(CheckValue)  ;          }
           
得到 CheckBoxList 选中值
 var CheckBoxList=document.all.checkList; 
            var objCheckBox,CheckValue="";
            for(i=0;i<CheckBoxList.rows.length;i++)   
            {   
                 objCheckBox   =    document.getElementById("checkList_"   +    i); 
                  if(objCheckBox.checked == true)
                   {
                         CheckValue += CheckBoxList.rows[i].cells[0].childNodes(1).innerText + ",";   
                   }
            }
            if(CheckValue!="")
            {
                  alert(CheckValue);                
            }
标签: c#