<script>
function radiovalue(obj)
{
for(i=0;i<obj.length;i++)
if(obj[i].checked)
{alert(obj[i].value);
return;
}
}
</script>
<input type=radio name=myradio value=1 checked>1
<input type=radio name=myradio value=2>2
<input type=radio name=myradio value=3>3
<input type=radio name=myradio value=4>4
<input type=button onclick=radiovalue(document.all.myradio)>

解决方案 »

  1.   

    for (i=0; i<RadioName.length; i++){
       alert(RadioName[i].value)
    }
      

  2.   

    先把Radio的名字取成一样
    给你一个方法你可以输入一个Radio、或Checkbox的名字用
    都要用
    如"表单名","Radio或checkbox名字","^"
    函数会返回一个字符串你可以直接用这个函数试一试吧!
    //--- 方法名: getCheckedString(AFormName,AChkName,ADivStr)
    //--- 功能: 取得单选框中的值
    //--- 返回: 选中单选框的值,如没有选中返回"";
    //---     AFormName: 所在的Form名
    //---     AChkName: CheckBox列表的名 
    //---     ADivStr: 分割字符串
    //--- 创建日期:     2002-04-10  最近更新日期:   2002-04-10
    //--- 创建程序员:     xg_delayth  最近更新程序员: xg_delayth
      function getCheckedString(AFormName,AChkName,ADivStr){
        var collection,i,tmpValue="";
        try{
          collection=document.all[AChkName];
          if (1<collection.length){
            for (i=0;i<collection.length;i++){
              if (true==collection[i].checked && collection[i].value!=""){
                tmpValue=tmpValue+collection[i].value+ADivStr;
              }
            }
            if (""!=tmpValue) return tmpValue.substring(0,tmpValue.lastIndexOf(ADivStr));
            else return "";
          } else{
            if (eval(AFormName+"."+AChkName+".checked")){
              return eval(AFormName+"."+AChkName+".value");
            } else{
              return "";
            }
          }
        } catch(e){
          return "";
        }
      }
      

  3.   

    <input type=radio name=myradio onClick="getValue(1)">1
    <input type=radio name=myradio onClick="getValue(2)">2
    <input type=radio name=myradio onClick="getValue(3)">3
    <input type=radio name=myradio onClick="getValue(4)">4
    Ok?