如何判定RADIO的选定? 不用循环,只需要判断:document.log.cc.value的值就可以了。这是javascript的问题嘛。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function subSelect() { var setselect; var j=0; for(i=0;i<document.form_info.elements.length;i++) { setselect = document.form_info.elements[i]; if (setselect.type=="radio") { //alert("setselect.checked="+setselect.checked); if (setselect.checked) { //alert("setselect.value="+setselect.value); j = 1+parseInt(setselect.value); parent.selEnd(document.all.tabCustom.rows(j).cells(5).innerText,document.all.tabCustom.rows(j).cells(2).innerText); } } } } <HTML><HEAD><META NAME="GENERATOR" Content="Microsoft FrontPage 4.0"><TITLE></TITLE></HEAD><BODY><form name="log"><P><INPUT name=cc type=radio value=a>a<INPUT name=cc type=radio value=b>b<INPUT name=cc type=radio value=c>c</P><INPUT name=button1 type=button value=Button onclick="jscript:select4()"></form></BODY><script language="jscript"> function select4() { var cid; var flag; flag=false; for(var i=0;i<=document.log.cc.length;i++) { if(document.log.cc[i].checked) { cid=document.log.cc[i].value; flag=true; break; } }alert(cid); } </script></HTML>加分 To 小马:你的方法我试验了一下,但只有一个radio的时候,却取不出数值来。<html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><script language="jscript">function subSelect(){var setselect;for(i=0;i<=document.f.a.length;i++){ setselect = document.f.a[i]; if (setselect.type=="radio") { if (setselect.checked) { alert("setselect.value="+setselect.value); } }}}</script> </head><body bgcolor="#FFFFFF" text="#000000"><form name="f" method="post" action=""> <input type="radio" name="a" value="a"> a<br> <input type="submit" name="Submit" value="Submit" onclick="subSelect()"></form></body></html>-------------------------------------------------------------------------To icystone:你的方法与小马有同样的问题。 将icystone的改为:<HTML><HEAD><META NAME="GENERATOR" Content="Microsoft FrontPage 4.0"><TITLE></TITLE></HEAD><BODY><form name="log"><P><INPUT name=cc type=radio value=a>a<INPUT name=cc type=radio value=b>b<INPUT name=cc type=radio value=c>c</P></P><INPUT name=button1 type=button value=Button onclick="jscript:select4()"></form></BODY><script language="jscript">function select4(){ var cid; var flag; flag=false; if(document.log.cc.length>0){ for(var i=0;i<=document.log.cc.length;i++) if(document.log.cc[i].checked){ cid=document.log.cc[i].value; flag=true; break; } } else if(document.log.cc.checked){ cid=document.log.cc.value; flag=true; } alert(cid); }</script></HTML> 好象还有问题吧:什么都不选时,但有出现问题:错误:document.log.cc[...].checked 不是对象。代码:0----------------------------------------------------------------??????????????? <HTML><HEAD><META NAME="GENERATOR" Content="Microsoft FrontPage 4.0"><TITLE></TITLE></HEAD><BODY><form name="log"><P><INPUT name=cc type=radio value=a>a<P><INPUT name=cc type=radio value=b>b<P><INPUT name=cc type=radio value=c>c<INPUT name=button1 type=button value=Button onclick="jscript:select4()"></form></BODY><script language="jscript">function select4(){ var cid; var flag; flag=false;if(document.log.cc.length>0){for(var i=0;i<=document.log.cc.length;i++)if(document.log.cc[i].checked){ cid=document.log.cc[i].value; flag=true; break;}}else if(document.log.cc.checked){ qcid=document.log.cc.value;flag=true; }if(!flag){ alert("no Selected");}else{ alert(cid); }}</script></HTML> ------------------------------------目的提示选择,出现同上错误。 你使用的方法是把radio框当成数组,你在页面里再加一个raido,也是同名,让他不显示就行了。<input type= raido name= style="display:none"> 错误依旧,请COPY上面代码测试 天天:在你那里实现alert("no Selected")了吗? 你在试一试:<HTML><HEAD><META NAME="GENERATOR" Content="Microsoft FrontPage 4.0"><TITLE></TITLE></HEAD><BODY><form name="log"><P><INPUT name=cc type=radio value=a>a<P><INPUT name=cc type=radio value=b>b<P><INPUT name=cc type=radio value=c>c<INPUT name=button1 type=button value=Button onclick="jscript:select4()"></form></BODY><script language="jscript">function select4(){ var cid; var flag; flag=false; if(document.log.cc.length>0){ for(var i=0;i<document.log.cc.length;i++) if(document.log.cc[i].checked){ cid=document.log.cc[i].value; flag=true; } } else{ if(document.log.cc.checked){ cid=document.log.cc.value; flag=true; } } if(flag){ alert(cid); } else{ alert("no Selected"); }}</script></HTML> 楼上的写法正确的,也可以判断后加break。 我建议加上个隐藏的,因为如果就一个radio,不是数组,再用以上的方法出错。 jsp中超链接实现提交表单 获取验证码图片问题. 关于JSP中数据提交的问题,,急急急!!! 【请教】struts2 generator标签生成的集合应用到if标签test中作为条件不能生效 请高手指教JSP 内存溢出问题 求助:如何使用Tomcat构建二级域名和虚拟主机?? 如何得到指定日期 如何只让session ID只通过URL传递,不放到Cookie里面 HttpClient 4.1 登录小米官网记录登录状态访问其他页面 求高手解决! 字符串比较问题 关于Jsp文件上传的问题 请各位列举你所知道有jsp源程下载的地方
{
var setselect;
var j=0;
for(i=0;i<document.form_info.elements.length;i++)
{
setselect = document.form_info.elements[i];
if (setselect.type=="radio")
{
//alert("setselect.checked="+setselect.checked);
if (setselect.checked)
{
//alert("setselect.value="+setselect.value);
j = 1+parseInt(setselect.value);
parent.selEnd(document.all.tabCustom.rows(j).cells(5).innerText,document.all.tabCustom.rows(j).cells(2).innerText);
}
}
}
}
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<form name="log">
<P><INPUT name=cc type=radio value=a>a
<INPUT name=cc type=radio value=b>b
<INPUT name=cc type=radio value=c>c</P>
<INPUT name=button1 type=button value=Button onclick="jscript:select4()">
</form>
</BODY>
<script language="jscript">
function select4()
{
var cid;
var flag;
flag=false;
for(var i=0;i<=document.log.cc.length;i++)
{
if(document.log.cc[i].checked)
{
cid=document.log.cc[i].value;
flag=true;
break;
}
}alert(cid);
}
</script>
</HTML>
加分
你的方法我试验了一下,但只有一个radio的时候,却取不出数值来。
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="jscript">
function subSelect(){
var setselect;
for(i=0;i<=document.f.a.length;i++)
{
setselect = document.f.a[i];
if (setselect.type=="radio")
{
if (setselect.checked)
{
alert("setselect.value="+setselect.value);
}
}
}
}
</script>
</head><body bgcolor="#FFFFFF" text="#000000">
<form name="f" method="post" action="">
<input type="radio" name="a" value="a">
a<br> <input type="submit" name="Submit" value="Submit" onclick="subSelect()">
</form>
</body>
</html>
-------------------------------------------------------------------------
To icystone:
你的方法与小马有同样的问题。
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<form name="log">
<P><INPUT name=cc type=radio value=a>a
<INPUT name=cc type=radio value=b>b
<INPUT name=cc type=radio value=c>c</P></P>
<INPUT name=button1 type=button value=Button onclick="jscript:select4()">
</form>
</BODY>
<script language="jscript">
function select4(){
var cid;
var flag;
flag=false;
if(document.log.cc.length>0){
for(var i=0;i<=document.log.cc.length;i++)
if(document.log.cc[i].checked){
cid=document.log.cc[i].value;
flag=true;
break;
}
}
else
if(document.log.cc.checked){
cid=document.log.cc.value;
flag=true;
}
alert(cid);
}
</script>
</HTML>
错误:document.log.cc[...].checked 不是对象。
代码:0
----------------------------------------------------------------
???????????????
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<form name="log">
<P><INPUT name=cc type=radio value=a>a
<P><INPUT name=cc type=radio value=b>b
<P><INPUT name=cc type=radio value=c>c
<INPUT name=button1 type=button value=Button onclick="jscript:select4()">
</form>
</BODY>
<script language="jscript">
function select4(){
var cid;
var flag;
flag=false;
if(document.log.cc.length>0){
for(var i=0;i<=document.log.cc.length;i++)
if(document.log.cc[i].checked){
cid=document.log.cc[i].value;
flag=true;
break;
}
}
else
if(document.log.cc.checked){
qcid=document.log.cc.value;
flag=true;
}
if(!flag){
alert("no Selected");
}
else{
alert(cid);
}
}
</script>
</HTML> ------------------------------------
目的提示选择,出现同上错误。
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<form name="log">
<P><INPUT name=cc type=radio value=a>a
<P><INPUT name=cc type=radio value=b>b
<P><INPUT name=cc type=radio value=c>c
<INPUT name=button1 type=button value=Button onclick="jscript:select4()">
</form>
</BODY>
<script language="jscript">
function select4(){
var cid;
var flag;
flag=false; if(document.log.cc.length>0){
for(var i=0;i<document.log.cc.length;i++)
if(document.log.cc[i].checked){
cid=document.log.cc[i].value;
flag=true;
}
}
else{
if(document.log.cc.checked){
cid=document.log.cc.value;
flag=true;
}
}
if(flag){
alert(cid);
}
else{
alert("no Selected");
}
}
</script>
</HTML>