Hide and show table based on radiobutton
Hi,
I have 2 radiobuttons "yes", "no". "No" is selected as default. If "No" is selected, then a table should be hidden.
If "Yes" is selected, the table should be shown.
I have used the below code, but it is not working:
- <asp:RadioButton ID="rbGuestTravelNo" Text="No" runat="server" Checked="True" GroupName="GuestTravel" />
- <asp:RadioButton ID="rbGuestTravelYes" Text="Yes" runat="server" GroupName="GuestTravel" />
- <table id="tblTravelList" >
<tr id="trGuestTravel" >
<td colspan="4">
<asp:Label ID="lblGuestTravelInfo" Text="please fill the information below: " runat="server"></asp:Label>
</td>
</tr>
I have used the below jquery, but it is not working. I have tried setting alerts, even alerts are not getting shown.
- $(document).ready(function () {
$("input[name=GuestTravel]:radio").change(function () {
if ($(this).val() == "rbGuestTravelYes") {
if ($(this).is(":checked")) {
$('#tblTravelList').show();
}
}
else {
$('#tblTravelList').hide();
}
});
});
How to fix this?
Thanks