JS获取单选与多选按纽的值

//求单选按纽的值,适用单选项及多选项。未选返回false;有选择项,返回选项值。
function CheckRadio(theRadio){
    var theRadioLen = theRadio.length;
    var theRadioValue = false;
    if (theRadioLen == undefined){
        if (theRadio.checked){
            theRadioValue = theRadio.value;
        }
    }else{
       
  for (theRadioI=0;theRadioI<theRadioLen;theRadioI++){
            if (theRadio[theRadioI].checked){
                theRadioValue = theRadio[theRadioI].value;
                break;
            }
        }
    }
    return theRadioValue;
}

theRadio这个取值:表单名.元素名称

posted on 2009-12-26 14:15  韩显川  阅读(444)  评论(0)    收藏  举报

导航