不用循环,只需要判断:
document.log.cc.value的值就可以了。
这是javascript的问题嘛。

解决方案 »

  1.   

    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);
    }
    }
    }
    }
      

  2.   

    <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>
    加分
      

  3.   

    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:
    你的方法与小马有同样的问题。
      

  4.   

    将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>
      

  5.   

    好象还有问题吧:什么都不选时,但有出现问题:
    错误:document.log.cc[...].checked 不是对象。
    代码:0
    ----------------------------------------------------------------
    ???????????????
      

  6.   

    <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> ------------------------------------
    目的提示选择,出现同上错误。
      

  7.   

    你使用的方法是把radio框当成数组,你在页面里再加一个raido,也是同名,让他不显示就行了。<input type= raido name= style="display:none">
      

  8.   

    错误依旧,请COPY上面代码测试
      

  9.   

    天天:在你那里实现alert("no Selected")了吗?
      

  10.   

    你在试一试:
    <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> 
      

  11.   

    楼上的写法正确的,也可以判断后加break。
      

  12.   

    我建议加上个隐藏的,因为如果就一个radio,不是数组,再用以上的方法出错。