<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.kjueaiud.com/