基本上,我試圖添加我的Radio Buttons
腳本文件,當用戶單擊另一個時,將刪除所有選定的按鈕。基本上它會阻止用戶選擇超過1 Radio Button
。但是,我不能。這是我的Java腳本代碼:無法訪問Java腳本文件夾
$().ready(function() {
var $allAccountSelectionRadios = $('.AccountSelectionRadio > input:radio');
$allAccountSelectionRadios.click(function() {
$allAccountSelectionRadios.not(this).each(function() {
this.checked = false;
});
});
});
,這裏是我的asp.net代碼:
<head runat="server">
<title>Lab 11 - Exception Handling and Error Logging</title>
<script src="Scripts/jquery-3.0.0.js"></script>
<script src="script/AccountPageScript.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<div id="Div1" runat="server">
<asp:Panel ID="AccountPanel" runat="server" GroupingText="Account Details" Visible="true">
<asp:Repeater ID="AccountInfoRepeater" runat="server" Visible="true">
<HeaderTemplate>
<table>
<thead>
<asp:TableHeaderCell ColumnSpan="2" runat="server" HorizontalAlign="Left">Account Id</asp:TableHeaderCell>
<asp:TableHeaderCell runat="server" HorizontalAlign="Left">Account Type</asp:TableHeaderCell>
<asp:TableHeaderCell runat="server" HorizontalAlign="Left">Balance</asp:TableHeaderCell>
<asp:TableHeaderCell runat="server" HorizontalAlign="Left">Currency</asp:TableHeaderCell>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:RadioButton ID="AccountSelectionRadioButton" runat="server" />
</td>
<td>
<asp:Label ID="AccountIDLabel" runat="server" Text='<%# Eval("Id") %>' />
</td>
<td>
<asp:Label ID="AccountTypeLabel" runat="server" Text='<%# Eval("Type") %>' />
</td>
<td>
<asp:Label ID="AmountLabel" runat="server" Text='<%# Eval("Amount") %>' />
</td>
<td>
<asp:Label ID="CurrencyLabel" runat="server" Text='<%# Eval("Currency") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<div></div>
<asp:Label ID="EnterAmountLabel" runat="server" Text="Enter Amount: " />
<asp:TextBox ID="WithdrawalAmountTextBox" runat="server" />
<asp:Button ID="SubmitButton" runat="server" Text="Submit" />
<div></div>
<asp:CustomValidator ID="CustomValidator" runat="server" ErrorMessage="You have to select at least one account " OnServerValidate="ValidateAccountIdSelection" Display="None" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator" runat="server" ErrorMessage="You have to enter a double value" ControlToValidate="WithdrawalAmountTextBox" Display="None" />
<asp:CompareValidator ID="CompareValidator" runat="server" ErrorMessage="You have to enter a double value " ControlToValidate="WithdrawalAmountTextBox" Type="Double" Operator="DataTypeCheck" Display="None" />
<div></div>
<asp:ValidationSummary ID="ValidationSummary" runat="server" />
</asp:Panel>
<asp:Panel ID="ErrorPanel" runat="server" Visible="false">
<asp:Label ID="SimpleBankErrorMessage" runat="server" />
</asp:Panel>
</div>
</form>
</body>
你有什麼想法,是什麼原因導致這個問題,或者你有任何鏈接,回答了這個題。
非常感謝你們,祝你有個美好的一天!
編輯:
這裏是HTML生成的代碼:
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<script src="/WebResource.axd?d=pynGkmcFUV13He1Qd6_TZDo7pde1PlC3CEuIL05u8Q1xzcqV3PrxQf6BV-yOWDawu00wwYzaAVDc3H21VtA9QA2&t=635588690558757176" type="text/javascript"> </script>
<script src="/WebResource.axd?d=x2nkrMJGXkMELz33nwnakICvsGmK5SdM9dk67DGoGLRbDkaJ4AV4SDiDiYXmeJzOvX1FlDmSjt4uSO7vYhQSbfgakaHhNd17j5pdlKG7J5s1&t=635588690558757176" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]>
</script>
我改變了我的與你的代碼,但它沒有幫助。我很確定代碼是正確的(它在作業中給出)。是的,也許你是對的,但這是作業,所以我們需要這樣做 –
你可以分享生成的HTML :)然後我可以看看它:) – Kiksen
是的當然,我會編輯我的問題: ) –