<form name="f1" method="POST" onsubmit="return CheckRadio(this)" action="test_Radio.php" >
  <p><input type="radio" name="test" value="a" checked>a</p>
  <p><input type="radio" name="test" value="b">b</p>
  <p><input type="submit" value="提交" name="B1"></p>
</form>
if(f1.elements[0].checked){alert("a")}
else if(f1.elements[1].checked){alert("b")}

解决方案 »

  1.   

    another mathod:<input name="radiobutton" type="radio" value="1" checked>
    <input name="radiobutton" type="radio" value="2">
    <input name="radiobutton" type="radio"  value="3">var a=document.getElementsByTagName("radio")
    for(i=o;i<a.length;i++)
    {
       if(a[i].checked)  alert(a[i].value)
    }
      

  2.   

    用你的Html控件方法(<input type="radio" value="MY" name="my">),得在点击提交之前先遍历radio,然后把选中的值传给runat=server的隐藏按钮,再在服务器端提取这个隐藏按钮的值。
    换种方式:xxx.aspx中:
    <asp:RadioButton id="rd1" GroupName="rdGroup" value='rd1_Val' Text="rd1_Txt" Checked="True" AutoPostBack="False" runat="server" />
    <asp:RadioButton id="rd2" GroupName="rdGroup" value='rd2_Val' Text="rd2_Txt" Checked="False" AutoPostBack="False" runat="server" />xxx.aspx.cs中:
    string sSelVal = this.Request.Form["rdGroup"].ToString();//取值
      

  3.   

    <%@ Page language="c#" Codebehind="RadioButtonUsage.aspx.cs" AutoEventWireup="false" Inherits="systemWebUIWebControlsCs.RadioButtonUsage" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>RadioButtonUsage</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="FrmRadioButtonUsage" method="post" runat="server">
    How often do you take a holiday:
    <asp:RadioButton ID="RBtnMonthly" runat="server" Text="Monthly" GroupName="Holiday"></asp:RadioButton>
    <asp:RadioButton ID="RBtnQuarterly" runat="server" Text="Quarterly" GroupName="Holiday" Checked="True"></asp:RadioButton>
    <asp:RadioButton ID="RBtnHalfYearly" runat="server" Text="Half - Yearly" GroupName="Holiday"></asp:RadioButton>
    <asp:RadioButton ID="RBtnYearly" runat="server" Text="Yearly" GroupName="Holiday"></asp:RadioButton>
    <br>
    <asp:Button ID="BtnSubmit" Runat="server" Text="Submit"></asp:Button>
    <hr>
    <asp:Label ID="LblMessage" Runat="server"></asp:Label>
    </form>
    </body>
    </HTML>
      

  4.   

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace systemWebUIWebControlsCs
    {
    /// <summary>
    /// Summary description for RadioButtonUsage.
    /// </summary>
    public class RadioButtonUsage : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.RadioButton RBtnMonthly;
    protected System.Web.UI.WebControls.RadioButton RBtnQuarterly;
    protected System.Web.UI.WebControls.RadioButton RBtnHalfYearly;
    protected System.Web.UI.WebControls.RadioButton RBtnYearly;
    protected System.Web.UI.WebControls.Button BtnSubmit;
    protected System.Web.UI.WebControls.Label LblMessage;

    private void Page_Load(object sender, System.EventArgs e)
    {
    if(RBtnMonthly.Checked)
    LblMessage.Text="You Selected " + RBtnMonthly.Text;
    else if(RBtnQuarterly.Checked)
    LblMessage.Text="You Selected " + RBtnQuarterly.Text;
    else if(RBtnHalfYearly.Checked)
    LblMessage.Text="You Selected " + RBtnHalfYearly.Text;
    else if(RBtnYearly.Checked)
    LblMessage.Text="You Selected " + RBtnYearly.Text;

    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {    
    this.BtnSubmit.Click += new System.EventHandler(this.BtnSubmit_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void BtnSubmit_Click(object sender, System.EventArgs e)
    {
    if(RBtnMonthly.Checked)
    LblMessage.Text="You Selected " + RBtnMonthly.Text;
    else if(RBtnQuarterly.Checked)
    LblMessage.Text="You Selected " + RBtnQuarterly.Text;
    else if(RBtnHalfYearly.Checked)
    LblMessage.Text="You Selected " + RBtnHalfYearly.Text;
    else if(RBtnYearly.Checked)
    LblMessage.Text="You Selected " + RBtnYearly.Text;

    }
    }
    }