求單選按紐的值,適用單選項及多選項

發表于:2007-07-14來源:作者:點擊數: 標簽:
form name=frm input type=radio value=1 name=radioName input type=radio value=2 name=radioName input type=button onClick=alert(CheckRadio(this.form.radioName)); /form script language= java script !-- //求單選按紐的值,適用單選項及多選項。未
<form name="frm">
<input type="radio" value="1" name="radioName">
<input type="radio" value="2" name="radioName">
<input type="button" onClick="alert(CheckRadio(this.form.radioName));">
</form>
<script language="javascript">
<!--
//求單選按紐的值,適用單選項及多選項。未選返回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;
}
//-->
</script>

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97