0
3つのListItemを持つRadioButtonListがあります。ユーザーが選択すると、確認ボックスが表示されます。彼らがキャンセルを押すと、選択の変更を取り消すだけです。以下のコードは、IE 7,8,9のすべてでうまくいきます。IEでは、戻り値falseが実行された後でListItemsが選択されませんが、他のコードでは、選択が取り消され、私たちが望むように、以前に選択されたアイテムが選択されます。 Y U NO NO WORK IE?javascript関数がfalseを返すと、IEはRadioButtonListの選択を解除します
マークアップ:
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" AutoPostBack="False">
<asp:ListItem Selected="True" onClick="return confirmSubmit(this, event);">Value 1</asp:ListItem>
<asp:ListItem onClick="return confirmSubmit(this, event);">Value 2</asp:ListItem>
<asp:ListItem onClick="return confirmSubmit(this, event);">Value 3</asp:ListItem>
</asp:RadioButtonList>
Javascriptを:
function confirmSubmit(listItem, e) {
var agree = confirm("Do you really want to change the value?");
if (!agree) {
return false;
}
else {
document.forms[0].submit();
}
}