求单选按纽的值,适用单选项及多选项。未选返回FALSE;有选择项,返回选项值
类别: JavaScript教程
<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>
<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>
- 上一篇: 键盘和鼠标事件测试
- 下一篇: JS-让你的回车转为(SHIFT+)TAB
-= 资 源 教 程 =-
文 章 搜 索