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>