页面上有2组按钮
一组是A,B,另一组是 课程
怎么实现当选择A时,只有数学,英语,语文可以选择,将体育,音乐,美术单选按钮设为不可选
当选择B时,只有体育,音乐,美术 可以选择,将 数学,英语,语文 设置为不可选Change 函数该怎么写,
<td>
<%=Html.RadioButton("Name.pType", 1, new { onclick = "Change(this)" })%>A
%=Html.RadioButton("Name.pType", 2, new { onclick = "Change(this)" })%>B
</td>
<td>
<%=Html.RadioButton("Name.type",0) %>数学
<%=Html.RadioButton("Name.type",1) %>语文
<%=Html.RadioButton("Name.type",2) %>英语 <%=Html.RadioButton("Name.type",3) %>体育
<%=Html.RadioButton("Name.type",4) %>音乐
<%=Html.RadioButton("Name.type",5) %>美术 </td>
一组是A,B,另一组是 课程
怎么实现当选择A时,只有数学,英语,语文可以选择,将体育,音乐,美术单选按钮设为不可选
当选择B时,只有体育,音乐,美术 可以选择,将 数学,英语,语文 设置为不可选Change 函数该怎么写,
<td>
<%=Html.RadioButton("Name.pType", 1, new { onclick = "Change(this)" })%>A
%=Html.RadioButton("Name.pType", 2, new { onclick = "Change(this)" })%>B
</td>
<td>
<%=Html.RadioButton("Name.type",0) %>数学
<%=Html.RadioButton("Name.type",1) %>语文
<%=Html.RadioButton("Name.type",2) %>英语 <%=Html.RadioButton("Name.type",3) %>体育
<%=Html.RadioButton("Name.type",4) %>音乐
<%=Html.RadioButton("Name.type",5) %>美术 </td>
用这个标签,如果选这组,另一组不可见
<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>
<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
<%=Html.RadioButton("Name.pType", 2, new { onclick = "Change(2)" })%>B
</td>
<td>
<%=Html.RadioButton("Name.type",0) %>数学
<%=Html.RadioButton("Name.type",1) %>语文
<%=Html.RadioButton("Name.type",2) %>英语 <%=Html.RadioButton("Name.type",3) %>体育
<%=Html.RadioButton("Name.type",4) %>音乐
<%=Html.RadioButton("Name.type",5) %>美术
</td>
</tr>
</table>
<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
<%=Html.RadioButton("Name.pType", 2, new { onclick = "Change(2)" })%>B
</td>
<td>
<%=Html.RadioButton("Name.type",0) %>数学
<%=Html.RadioButton("Name.type",1) %>语文
<%=Html.RadioButton("Name.type",2) %>英语 <%=Html.RadioButton("Name.type",3) %>体育
<%=Html.RadioButton("Name.type",4) %>音乐
<%=Html.RadioButton("Name.type",5) %>美术
</td>
</tr>
</table>
<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
<%=Html.RadioButton("Name.pType", 2, new { onclick = "Change(2)" })%>B
</td>
<td>
<%=Html.RadioButton("Name.type",0) %>数学
<%=Html.RadioButton("Name.type",1) %>语文
<%=Html.RadioButton("Name.type",2) %>英语 <%=Html.RadioButton("Name.type", 3, new {disabled = "disabled"})%>体育
<%=Html.RadioButton("Name.type", 4, new { disabled = "disabled" })%>音乐
<%=Html.RadioButton("Name.type", 5, new { disabled = "disabled" })%>美术
</td>
</tr>
</table>