js 得到 radiobuttonlist和CheckBoxList 选中值

得到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);                
            }
posted @ 2009-09-27 18:47  若心似海  阅读(2041)  评论(0编辑  收藏  举报