有三组radiobuttonlist,点击邮政包裹时,支付方式中的“货到付款”不可选,点击支付方式中的“货付付款”和“邮政汇款”时,支付银行一组都不可。要在客户端用JS处理。试了一个下午,都没有搞定,望高手帮忙。
<tr bgColor="#f7fbff">
<td vAlign="middle" align="right" bgColor="#f7fbff" height="20"><asp:requiredfieldvalidator id="RequiredFieldValidator4" runat="server" ErrorMessage="*" ControlToValidate="rblDeliverMode"></asp:requiredfieldvalidator>&nbsp;</td>
<td align="left" bgColor="#f7fbff">送货方式:</td>
<td colSpan="2"><FONT face="宋体"><asp:radiobuttonlist id="rblDeliverMode" runat="server" Width="158px" RepeatDirection="Horizontal">
<asp:ListItem Value="送货上门">送货上门</asp:ListItem>
<asp:ListItem Value="邮政包裹">邮政包裹</asp:ListItem>
</asp:radiobuttonlist></FONT></td>
</tr>
<tr id="trMarketPrice" bgColor="#f7fbff">
<td vAlign="middle" align="right" bgColor="#f7fbff" height="20"><asp:requiredfieldvalidator id="Requiredfieldvalidator5" runat="server" ErrorMessage="*" ControlToValidate="rblPayMode"></asp:requiredfieldvalidator>&nbsp;</td>
<td align="left" bgColor="#f7fbff">支付方式:</td>
<td colSpan="2"><FONT face="宋体"><asp:radiobuttonlist id="rblPayMode" runat="server" Width="336px" RepeatDirection="Horizontal">
<asp:ListItem Value="货到付款">货到付款</asp:ListItem>
<asp:ListItem Value="在线支付">在线支付</asp:ListItem>
<asp:ListItem Value="个人银行汇款">个人银行汇款</asp:ListItem>
<asp:ListItem Value="邮政汇款">邮政汇款</asp:ListItem>
</asp:radiobuttonlist></FONT></td>
</tr>
<tr id="trShopPrice" bgColor="#f7fbff">
<td vAlign="middle" align="right" bgColor="#f7fbff" height="20">&nbsp;</td>
<td align="left" bgColor="#f7fbff">支付银行:</td>
<td colSpan="2"><asp:radiobuttonlist id="rblPayBank" runat="server" Width="384px" RepeatDirection="Horizontal">
<asp:ListItem Value="工商银行">工商银行</asp:ListItem>
<asp:ListItem Value="招商银行">招商银行</asp:ListItem>
<asp:ListItem Value="建设银行">建设银行</asp:ListItem>
<asp:ListItem Value="中国银行">中国银行</asp:ListItem>
<asp:ListItem Value="农业银行">农业银行</asp:ListItem>
</asp:radiobuttonlist></td>
</tr>

解决方案 »

  1.   

    不用Js也是可以的啊!!!
    你直接通过在服务器端radiobuttonlist的SelectedIndexChanged事件来实现啊!
    需要注意的是设置radiobuttonlist的AutoPoatBack属性为True
      

  2.   

    <HTML>
    <HEAD>
    <title>Test</title>
    <script language="javascript">
    function clickBody()
    {
       if(event.srcElement.value=="邮政包裹")
       {
          var obj = document.getElementsByName("rblPayMode");
          for(i=0;i<obj.length;i++)
          {
             if(obj[i].value=="货到付款")
             {
                obj[i].disabled=true;
             }
          }
       }
       if((event.srcElement.value=="货到付款")||(event.srcElement.value=="邮政汇款"))
       {
          var obj = document.getElementsByName("rblPayBank");
          for(i=0;i<obj.length;i++)
          {
                obj[i].disabled=true;
          }
       }
    }
    </script>
    </HEAD>
    <body MS_POSITIONING="GridLayout" onclick="clickBody()">
    <form id="Form1" method="post" runat="server">
    <TABLE id="Table1" width="100%" cellSpacing="1"cellPadding="1" width="300">
    <tr bgColor="#f7fbff">
    <td vAlign="middle" align="right" bgColor="#f7fbff" height="20"><asp:requiredfieldvalidator id="RequiredFieldValidator4" runat="server" ErrorMessage="*" ControlToValidate="rblDeliverMode"></asp:requiredfieldvalidator>&nbsp;</td>
    <td align="left" bgColor="#f7fbff">送货方式:</td>
    <td colSpan="2"><FONT face="宋体"><asp:radiobuttonlist id="rblDeliverMode" runat="server" Width="158px" RepeatDirection="Horizontal">
    <asp:ListItem Value="送货上门">送货上门</asp:ListItem>
    <asp:ListItem Value="邮政包裹">邮政包裹</asp:ListItem>
    </asp:radiobuttonlist></FONT></td>
    </tr>
    <tr id="trMarketPrice" bgColor="#f7fbff">
    <td vAlign="middle" align="right" bgColor="#f7fbff" height="20"><asp:requiredfieldvalidator id="Requiredfieldvalidator5" runat="server" ErrorMessage="*" ControlToValidate="rblPayMode"></asp:requiredfieldvalidator>&nbsp;</td>
    <td align="left" bgColor="#f7fbff">支付方式:</td>
    <td colSpan="2"><FONT face="宋体"><asp:radiobuttonlist id="rblPayMode" runat="server" Width="336px" RepeatDirection="Horizontal">
    <asp:ListItem Value="货到付款">货到付款</asp:ListItem>
    <asp:ListItem Value="在线支付">在线支付</asp:ListItem>
    <asp:ListItem Value="个人银行汇款">个人银行汇款</asp:ListItem>
    <asp:ListItem Value="邮政汇款">邮政汇款</asp:ListItem>
    </asp:radiobuttonlist></FONT></td>
    </tr>
    <tr id="trShopPrice" bgColor="#f7fbff">
    <td vAlign="middle" align="right" bgColor="#f7fbff" height="20">&nbsp;</td>
    <td align="left" bgColor="#f7fbff">支付银行:</td>
    <td colSpan="2"><asp:radiobuttonlist id="rblPayBank" runat="server" Width="384px" RepeatDirection="Horizontal">
    <asp:ListItem Value="工商银行">工商银行</asp:ListItem>
    <asp:ListItem Value="招商银行">招商银行</asp:ListItem>
    <asp:ListItem Value="建设银行">建设银行</asp:ListItem>
    <asp:ListItem Value="中国银行">中国银行</asp:ListItem>
    <asp:ListItem Value="农业银行">农业银行</asp:ListItem>
    </asp:radiobuttonlist></td>
    </tr>
    </TABLE>
    </form>
    </body>
    </html>
      

  3.   

    不好意思,那个函数点了之后就不能恢复了。。
    改成下面的:
    function clickBody()
    {
    if(event.srcElement.name=="rblDeliverMode")
    {
        var obj = document.getElementsByName("rblPayMode");
    if(event.srcElement.value=="邮政包裹")
    {
    for(i=0;i<obj.length;i++)
    {
    if(obj[i].value=="货到付款")
    {
    obj[i].disabled=true;
    }
    }
    }
    else
    {
       for(i=0;i<obj.length;i++)
    {
    if(obj[i].value=="货到付款")
    {
    obj[i].disabled=false;
    }
    }
    }
    }
    if(event.srcElement.name=="rblPayMode")
    {
        var obj = document.getElementsByName("rblPayBank");
    if((event.srcElement.value=="货到付款")||(event.srcElement.value=="邮政汇款"))
    {
    for(i=0;i<obj.length;i++)
    {
    obj[i].disabled=true;
    }
    }
    else
    {
        for(i=0;i<obj.length;i++)
    {
    obj[i].disabled=false;
    }
    }
       }
    }
      

  4.   

    呵呵,我也贴一段:
    <%@ Page language="c#" Codebehind="RadioButton.aspx.cs" AutoEventWireup="false" Inherits="TestWeb.RadioButton" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>RadioButton</title>
    </HEAD>
    <script language="JavaScript">
    <!--
    function Func1(  )
    {
    if ( event.srcElement.value == "邮政包裹" )
    document.Form1.rblPayMode[0].disabled = true;
    else
    document.Form1.rblPayMode[0].disabled = false;
    }
    function Func2(  )
    {
    if ( event.srcElement.value == "货到付款" || event.srcElement.value == "邮政汇款" )
    {
    for( i=0;i< document.Form1.rblPayBank.length;i++ )
    {
    document.Form1.rblPayBank[i].disabled = true;
    }
    }
    else
    {
    for( i=0;i< document.Form1.rblPayBank.length;i++ )
    {
    document.Form1.rblPayBank[i].disabled = false;
    }
    }
    }
    //-->
    </script>
    <body>
    ..............
    </body>
    </HTML>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 TestWeb
    {
    /// <summary>
    /// RadioButton 的摘要说明。
    /// </summary>
    public class RadioButton : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4;
    protected System.Web.UI.WebControls.RadioButtonList rblDeliverMode;
    protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator5;
    protected System.Web.UI.WebControls.RadioButtonList rblPayMode;
    protected System.Web.UI.WebControls.RadioButtonList rblPayBank;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    this.rblDeliverMode.Attributes.Add( "onclick" , "javascript:Func1();");
    this.rblPayMode.Attributes.Add("onclick" , "javascript:Func2();");
    } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion
    }
    }
      

  5.   

    简化一下:
    <script language="JavaScript">
    <!--
    function Func1(  )
    {
    if ( event.srcElement.value == "邮政包裹" )
    document.Form1.rblPayMode[0].disabled = true;
    else
    document.Form1.rblPayMode[0].disabled = false;
    }
    function Func2(  )
    {
    if ( event.srcElement.value == "货到付款" || event.srcElement.value == "邮政汇款" )
    {
    for( i=0;i< document.Form1.rblPayBank.length;i++ )
    {
    document.Form1.rblPayBank[i].disabled = true;
    }
    }
    else
    {
    for( i=0;i< document.Form1.rblPayBank.length;i++ )
    {
    document.Form1.rblPayBank[i].disabled = false;
    }
    }
    }
    //-->
    </script> private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    this.rblDeliverMode.Attributes.Add( "onclick" , "javascript:Func1();");
    this.rblPayMode.Attributes.Add("onclick" , "javascript:Func2();");
    }