0
我想知道,如果有人可以幫助我一點JavaScript和MVC禁用鏈接。爲了給出一些背景......在我的應用程序中有一些小組,其中有個別商店的小組。以前,用戶可以選擇每個商店,但是我想更改應用程序以讓用戶選擇該組。這反過來會選擇該組下的所有個體商店,因爲該應用程序的基礎工作必須保持不變。的Javascript/jQuery的,如果所有選擇
這是現有的HTML網頁...我已經改變了各店鋪的複選框的風格被隱藏。還有一些javascript檢查全部,或取消選中Group標題下的所有商店。幫助位我需要的JavaScript現在的問題是,如果用戶點擊選擇,選擇鏈接變成了取消鏈接禁用,反之亦然。
如果有人可以幫助我會非常感激。如果需要更多信息,只需詢問!分別
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
function select(sectionId) {
toggle(sectionId, "checked");
}
function deselect(sectionId) {
toggle(sectionId, null);
}
function toggle(sectionId, checked) {
$('[section$=' + sectionId + ']').each(function() { $(this).attr('checked', checked); });
}
</script>
<div>
<% int i = 0; %>
<% Html.BeginForm(); %>
<% { %>
<% foreach (myApp.Web.Models.ShopGroup g in Model.Groups) %>
<% { %>
<div style="width:800px;">
<div style="border-bottom: 1px solid;">
<div style="font-weight: bold; width: 300px; float: left;">
<%: g.GroupHeader%>
</div>
<div style="line-height: 18px; vertical-align: middle; width: 250px; float: left;">
<a id="select" href="javascript:select(<%: i %>)" <%: ViewData["GROUP_ALL_SELECTED_" + g.GroupHeader] %>>
Select</a>/<a id="deselect" href="javascript:deselect(<%: i %>)" <%: ViewData["GROUP_ALL_SELECTED_" + g.GroupHeader] %>>
Deselect</a>
</div>
<div style="clear: both;">
</div>
</div>
</div>
<div style="margin-left: 10px; margin-top: 10px;">
<% foreach (myApp.Data.Shop shop in g.Shops) %>
<% { %>
<div style="float: left; line-height: 18px; padding: 2px; margin: 2px; vertical-align: middle;
border: 1px solid; width: 282px;">
<input type="checkbox" style="display:none;" section="<%: i %>" name="SHOP_<%: shop.ShopID %>" <%: ViewData["SHOP_" + shop.ShopID] %>
style="vertical-align: middle; padding-left: 5px;" />
<%= Html.TrimTextToLength(shop.Name)%>
</div>
<% } %>
</div>
<div style="clear: both; margin-bottom: 15px;">
</div>
<% i++; %>
<% } %>
<br />
<br />
<div class="btnFooter">
<input type="submit" value="Update" />
</div>
<div style="clear: both;">
</div>
<% } %>
</div>
</asp:Content>