JS单选按钮获值传递
<inputtype="radio"name="stp"value="company">inputname="uname"type="text"class="input"...
<input type="radio" name="stp" value="company" >
input name="uname" type="text" class="input" id="uname">
<input class=buttons onClick=check_id_window(document.addnew.stp.chcked) type=submit value="检测ID" name=Check_ID>
以上单选按钮获值并传递,为什么得不到单选按钮的值?输出的值是"undefined",为什么? 展开
input name="uname" type="text" class="input" id="uname">
<input class=buttons onClick=check_id_window(document.addnew.stp.chcked) type=submit value="检测ID" name=Check_ID>
以上单选按钮获值并传递,为什么得不到单选按钮的值?输出的值是"undefined",为什么? 展开
展开全部
<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>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询