gpt4 book ai didi

javascript - If 和 Else 语句始终输出 If

转载 作者:行者123 更新时间:2023-11-28 18:00:21 25 4
gpt4 key购买 nike

我正在摆弄以前存在的代码片段并遇到了问题。每当我尝试输入不应用 to If 语句的输入时,它总是给出 If 输出。另外,我希望您是否已发送到某个 URL(例如 Google),而不是说“已批准”,但我不确定这两者是否有解决方案。

function myFunction() {
var a = document.getElementById("text_a").value;

if (a == "02035", "02048", "02067") {
document.getElementById("answer").innerHTML = "Approved";
} else {
document.getElementById("answer").innerHTML = "Our service currently isn't available in your area! Try again soon!";
}
}
<p>Enter Zip Code </p>
<input id="text_a" type="text" />
<p id="answer"></p>
<button onclick="myFunction()">Check</button>

最佳答案

可能您需要更改 if 语句中的条件:

if (a == "02035" || a == "02048" || a == "02067"){
document.getElementById("answer").innerHTML="Approved";
}
else{
document.getElementById("answer").innerHTML="Our service currently isn't available in your area! Try again soon!";
}

关于javascript - If 和 Else 语句始终输出 If,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43624131/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com