我开发了一个MVC3应用程序,因为我想使用Check boxlist,我有三个复选框。我的要求是,当我勾选复选框时,它只接受复选框,而不是多个剩余的复选框应该取消选中,如RadioButton列表类型。
请帮助我......我该如何解决这个问题?
这是我的观看代码
@{
ViewBag.Title = "MenuCategories";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script type="text/javascript">
$(function () {
enable_cb();
$("#ChbkPickup").click(enable_cb);
});
function enable_cb() {
if (this.checked) {
$("input.ccc").removeAttr("disabled");
} else {
$("input.group1").attr("disabled", true);
}
}
$(function () {
$('.example-container > pre').each(function (i) {
eval($(this).text());
});
});
</script>
@using (Html.BeginForm("OrderCompleted", "Home", FormMethod.Post, new { id = "myForm" }))
{
@Html.ValidationSummary(true)
Delivery:<input type="checkbox" name="Deliver" value="Deliver" id="Chbkdeliver" />
Pickup: <input type="checkbox" name="Deliver" value="Pickup" id="ChbkPickup" class="group1" checked="checked" />
Dine In:<input type="checkbox" name="Deliver" value="Dinein" class="group1" id="ChbkDinein" />
}
答案 0 :(得分:0)
用这个
替换你所有的javascript标签<script type="text/javascript">
$(function () {
$("#myform :checkbox").click(function(){
$("#myform input:checked").attr("checked","");
$(this).attr("checked","checked");
});
});
</script>