页面上有2组按钮
一组是A,B,另一组是 课程
怎么实现当选择A时,只有数学,英语,语文可以选择,将体育,音乐,美术单选按钮设为不可选
当选择B时,只有体育,音乐,美术 可以选择,将 数学,英语,语文 设置为不可选Change 函数该怎么写,
<td>
<%=Html.RadioButton("Name.pType", 1, new { onclick = "Change(this)" })%>A &nbsp;&nbsp;
%=Html.RadioButton("Name.pType", 2, new { onclick = "Change(this)" })%>B
</td>
<td>
 <%=Html.RadioButton("Name.type",0) %>数学&nbsp;&nbsp;
 <%=Html.RadioButton("Name.type",1) %>语文&nbsp;&nbsp;
 <%=Html.RadioButton("Name.type",2) %>英语&nbsp;&nbsp; <%=Html.RadioButton("Name.type",3) %>体育&nbsp;&nbsp;
 <%=Html.RadioButton("Name.type",4) %>音乐&nbsp;&nbsp;
 <%=Html.RadioButton("Name.type",5) %>美术&nbsp;&nbsp;</td>

解决方案 »

  1.   

    Change里面遍历radio,判断value,设置disable=true就不可选了; 
      

  2.   

    初学,不用遍历,请直接帮我判断 value,给个列子,谢谢啊
      

  3.   

    <COLGROUP></COLGROUP> 定义多个列为一组列 html标签
    用这个标签,如果选这组,另一组不可见
      

  4.   

    4楼好像说错了,在服务器控件中应该是groupname分组,有对应的html标签,具体是什么你查下吧
      

  5.   

    按你的意思写了个例子<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm42.aspx.cs" Inherits="jquerytest.WebForm42" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>    <script src="jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <input id="Radio7" type="radio" name="cb" value="1" />aa
            <input id="Radio8" type="radio" name="cb" value="2" />bb
            <div id="div1">
            <input id="Radio1" type="radio" name="ck" />A
            <input id="Radio2" type="radio" name="ck" />B
            <input id="Radio3" type="radio" name="ck" />C
            </div>
            <div id="div2">
            <input id="Radio4" type="radio" name="kk" />D
            <input id="Radio5" type="radio" name="kk" />E
            <input id="Radio6" type="radio" name="kk" />F
            </div>
        </div>
        </form>
    </body>
    </html><script type="text/javascript">
        $(function() {
            $("input[name='cb']").change(function(i, k) {
                // 这里可以写些验证代码
                if ($("input[name='cb']:checked").val() == '1') {                $("#div1").hide();
                    $("#div2").show();
                }
                else{                $("#div2").hide();
                    $("#div1").show();
                }
            });
        })</script>
      

  6.   

    <script src="../../Scripts/jquery.js" type="text/javascript"></script>
      <script type="text/javascript">
        function Change(x) {
          if (x == 1) {
            $("input[name='Name.type']").each(function () {
              $(this).removeAttr("disabled");
              $(this).removeAttr("checked");
              if ($(this).val() == "3" || $(this).val() == "4" || $(this).val() == "6") {
                $(this).attr("disabled","disabled");
              }
            });
          }
          else {
            $("input[name='Name.type']").each(function () {
              $(this).removeAttr("disabled");
              $(this).removeAttr("checked");
              if ($(this).val() == "0" || $(this).val() == "1" || $(this).val() == "2") {
                $(this).attr("disabled","disabled");
              }
            });
          }
        }
      </script>
    <table>
    <tr>
    <td>
    <%=Html.RadioButton("Name.pType", 1, new { onclick = "Change(1)" })%>A &nbsp;&nbsp;
    <%=Html.RadioButton("Name.pType", 2, new { onclick = "Change(2)" })%>B
    </td>
    <td>
     <%=Html.RadioButton("Name.type",0) %>数学&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type",1) %>语文&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type",2) %>英语&nbsp;&nbsp; <%=Html.RadioButton("Name.type",3) %>体育&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type",4) %>音乐&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type",5) %>美术&nbsp;&nbsp;
    </td>
    </tr>
    </table>
      

  7.   

    本帖最后由 net_lover 于 2012-04-24 14:45:29 编辑
      

  8.   

    这样改
    <script src="../../Scripts/jquery.js" type="text/javascript"></script>
      <script type="text/javascript">
        function Change(x) {
          if (x == 1) {
            $("input[name='Name.type']").each(function () {
              $(this).removeAttr("disabled");
              $(this).removeAttr("checked");
              if ($(this).val() == "3" || $(this).val() == "4" || $(this).val() == "6") {
                $(this).attr("disabled","disabled");
              }
            });
          }
          else {
            $("input[name='Name.type']").each(function () {
              $(this).removeAttr("disabled");
              $(this).removeAttr("checked");
              if ($(this).val() == "0" || $(this).val() == "1" || $(this).val() == "2") {
                $(this).attr("disabled","disabled");
              }
            });
          }
        }
        window.onload = function () {
          Change(1);
        }
      </script>
    <table>
    <tr>
    <td>
    <%=Html.RadioButton("Name.pType", 1,true, new { onclick = "Change(1)" })%>A &nbsp;&nbsp;
    <%=Html.RadioButton("Name.pType", 2, new { onclick = "Change(2)" })%>B
    </td>
    <td>
     <%=Html.RadioButton("Name.type",0) %>数学&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type",1) %>语文&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type",2) %>英语&nbsp;&nbsp; <%=Html.RadioButton("Name.type",3) %>体育&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type",4) %>音乐&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type",5) %>美术&nbsp;&nbsp;
    </td>
    </tr>
    </table>
      

  9.   

    或者这样
    <script type="text/javascript">
        function Change(x) {
          if (x == 1) {
            $("input[name='Name.type']").each(function () {
              $(this).removeAttr("disabled");
              $(this).removeAttr("checked");
              if ($(this).val() == "3" || $(this).val() == "4" || $(this).val() == "6") {
                $(this).attr("disabled","disabled");
              }
            });
          }
          else {
            $("input[name='Name.type']").each(function () {
              $(this).removeAttr("disabled");
              $(this).removeAttr("checked");
              if ($(this).val() == "0" || $(this).val() == "1" || $(this).val() == "2") {
                $(this).attr("disabled","disabled");
              }
            });
          }
        }
      </script>
    <table>
    <tr>
    <td>
    <%=Html.RadioButton("Name.pType", 1, true, new { onclick = "Change(1)" })%>A &nbsp;&nbsp;
    <%=Html.RadioButton("Name.pType", 2, new { onclick = "Change(2)" })%>B
    </td>
    <td>
     <%=Html.RadioButton("Name.type",0) %>数学&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type",1) %>语文&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type",2) %>英语&nbsp;&nbsp; <%=Html.RadioButton("Name.type", 3, new {disabled = "disabled"})%>体育&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type", 4, new { disabled = "disabled" })%>音乐&nbsp;&nbsp;
     <%=Html.RadioButton("Name.type", 5, new { disabled = "disabled" })%>美术&nbsp;&nbsp;
    </td>
    </tr>
    </table>
      

  10.   

    我是从数据库读取 数据 选择A或B,也同时选择了A类的信息或者B类里的信息的。