Js中得到radiobuttonlist 和CheckBoxList 的值

得到radiobuttonlist 选中值:
View Code
1 var CheckBoxList=document.all.optButtonList;
2 var objCheckBox,CheckValue="";
3 for(i=0;i<CheckBoxList.rows.length;i++)
4 {
5 objCheckBox = document.getElementById('optButtonList'+ "_" + i);
6 if(objCheckBox.checked == true)
7 {
8 CheckValue = objCheckBox.value;
9 }
10 }
11 if(CheckValue!="")
12 {
13 alert(CheckValue) ; }
           
得到 CheckBoxList 选中值
 
View Code
1 var CheckBoxList=document.all.checkList;
2 var objCheckBox,CheckValue="";
3 for(i=0;i<CheckBoxList.rows.length;i++)
4 {
5 objCheckBox = document.getElementById("checkList_" + i);
6 if(objCheckBox.checked == true)
7 {
8 CheckValue += CheckBoxList.rows[i].cells[0].childNodes(1).innerText + ",";
9 }
10 }
11 if(CheckValue!="")
12 {
13 alert(CheckValue);
14 }
原文地址:https://www.cnblogs.com/wsl2011/p/2037690.html