以前もこれと同じような質問がありましたが、ユーザーが気が変わったので修正しなければなりませんでした。オプション0が選択されている場合は「リマインダー」が表示され、それ以外の場合は非表示にされるスクリプトに取り組んでいます。オプション2が選択されている場合は、「cc」を再表示する必要があります。それ以外の場合は、非表示のままにします。私の問題は、オプション0または2に関係なくイベントが発生すると、両方の領域が開くことです。私はそれらを別々に動作させるためにいくつかの助けを得ることができるかどうか疑問に思っていました。これがJSです:
$('#rbPType').change(function () {
var op1 = $(this).attr('value', '0');
var op2 = $(this).attr('value', '2');
if (op1) {
$('#remind').fadeIn();
} else {
$('#remind').fadeOut();
}
$(this).change(function () {
$('#remind').toggle();
});
if (op2) {
$('#cc').fadeIn();
} else {
$('#cc').fadeOut();
}
$(this).change(function () {
$('#cc').toggle();
});
});
HTML
<div class="another">
<label for="rbPType">Select One</label>
<asp:RadioButtonList runat="server" ID="rbPType" ClientIDMode="Static">
<asp:ListItem Value="0" Text="1"></asp:ListItem>
<asp:ListItem Value="1" Text="2"></asp:ListItem>
<asp:ListItem Value="2" Text="3"></asp:ListItem>
</asp:RadioButtonList>
</div>
<div id="remind">
<label for="ddlReminderMonth">Remind Me</label>
<asp:DropDownList runat="server" ID="ddlReminderMonth" AppendDataBoundItems="true" AutoPostBack="false" />
</div>
<div id="cc">
<label for="ddlReminderMonth">Remind Me Two</label>
<asp:DropDownList runat="server" ID="ddlReminderMonth" AppendDataBoundItems="true" AutoPostBack="false" />
</div>