ユーザーがアプリを起動するたびに、アプリはユーザーに "First" または "Second" を選択するよう求めます。ユーザーの選択が「First」の場合、メッセージ「TEST 1」が表示されます。ユーザーの選択が「Second」の場合、メッセージは「TEST 2」です。
何を選択しても、メッセージは常に「TEST 1」です。
コードの何が問題になっていますか?
どうすれば動作させることができますか?
var msg = new Windows.UI.Popups.MessageDialog("Choose first or second.", "Test");
// Add commands and set their command handlers
msg.commands.append(new Windows.UI.Popups.UICommand("First", commandInvokedHandler));
msg.commands.append(new Windows.UI.Popups.UICommand("Second", commandInvokedHandler));
// Set the command that will be invoked by default
msg.defaultCommandIndex = 1;
// Set the command to be invoked when escape is pressed
msg.cancelCommandIndex = 1;
// Show the message dialog
msg.showAsync();
if (msg = 1) {
// First Choice
var button = document.getElementById("button");
applyButton.addEventListener("click", buttonFirst, false);
} else {
// Second Choice
var button = document.getElementById("button");
applyButton.addEventListener("click", buttonSecond, false);
}
function buttonFirst(eventInfo) {
var greetingString = "TEST 1";
document.getElementById("first").innerText = greetingString;
}
function buttonSecond(eventInfo) {
var greetingString = "TEST 2";
document.getElementById("second").innerText = greetingString;
}