我已經開發了一個MVC3應用程序,我希望使用複選框列表,我有三個複選框。我的要求是,當我選中複選框時,只在複選框上接受複選框,而不應選中多餘的複選框,如RadioButton列表類型。我怎樣才能複選框列表只選擇MCV 3中使用jQuery選擇的一個項目
請幫我...我該如何解決這個問題?
這裏是我的視圖代碼
@{
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" />
}
所有的JavaScript代碼,你可以張貼一些代碼? – bvd
我問一個問題如何使一個複選框選中不是多個..我的代碼接受多個選擇。我在谷歌搜索http://stackoverflow.com/questions/1769621/how-to-make-an-checkboxlist-select-only-one-item-selected。但我怎麼能這樣稱呼。 – Victor
請檢查我想要的那樣的鏈接.... – Victor