I have two check box to chose multiple choices.
1. If i select radio button, i want check box "By post" is checked.
2. If i uncheck check box "By post", i want radio button is unchecked.
3. When i check in radio Add4, i want to show the div "anotherStatementAddress". And when i check in others, i want to hide div "anotherStatementAddress".
The result:
1. The first time i select radio button, "By post" is checked. But when i unchecked this, i select radio button again, "By post" is not checked.
2. is ok.
3. The first time i select radio Add4. Div "anotherStatementAddress" show, but when i chose another radio button, it doesn't hide.
Anyone help me? Thanks.
Here the code:
Jquery code
- $("#<%= rdoPostStatementReceiveMethod.ClientID %>").change(function() {
if (!$("#<%= cbPostStatementReceiveMethod.ClientID%>").is(':checked')) {
$("#<%= cbPostStatementReceiveMethod.ClientID%>").attr('checked', 'checked');
}
var rbvalue = $("#<%= rdoPostStatementReceiveMethod.ClientID %> input:checked").val();
if (rbvalue == '3') {
$("#anotherStatementAddress").show();
}
else {
$("#anotherStatementAddress").hide();
$("#<%= txtStatementAddress.ClientID %>").val('');
$("#<%= txtStatementCity.ClientID %>").val('');
$("#<%= drlStatementCountry.ClientID%>").val('VN');
}
});
$("#<%= cbPostStatementReceiveMethod.ClientID%>").change(function() {
if ($(this).is(':checked')) {
}
else {
$("#<%= rdoPostStatementReceiveMethod.ClientID %> input:checked").removeAttr("checked");
}
});
Client code
- <asp:CheckBox ID="cbPostStatementReceiveMethod" runat="server" />By post
<asp:RadioButtonList ID="rdoPostStatementReceiveMethod" runat="server">
<asp:ListItem Value="0">Add1</asp:ListItem>
<asp:ListItem Value="1">Add2</asp:ListItem>
<asp:ListItem Value="2">Add3</asp:ListItem>
<asp:ListItem Value="3">Add4</asp:ListItem>
</asp:RadioButtonList>
<div id="anotherStatementAddress" style="display: none;">
<div class="titleind">Địa chỉ khác:</div>
<br />
Add - <asp:TextBox ID="txtStatementAddress" runat="server" CssClass="alphabetNumber"></asp:TextBox>
- City -
<asp:TextBox ID="txtStatementCity" runat="server" MaxLength="20" CssClass="alphabetNumber"></asp:TextBox>
Nation - <asp:DropDownList ID="drlStatementCountry" runat="server" Width="200px">
</asp:DropDownList>
</div>
<br />
<asp:CheckBox ID="cbEmailStatementReceiveMethod" runat="server" />By Email