问题描述
嗨
选择任何一个国家/地区的'或''的正确语法是什么?
来自下拉列表列表?
这是我认为应该工作的,但似乎没有。
if(form.country.options [chooseSelect] .value ==" FR" ||" DE" ||" UK"){
这样做
}其他{
这样做
}
感谢您的帮助。
Roy
Hey Roy,
你到底有什么是一个单独的比较
form.country.options [chooseSelect] .value和两个OR条件将
总是评估为真。
尝试:
if(form.country.options [chooseSelect] .value ==" FR" ||
form.country.options [chooseSelect] .value ==" DE" ||
form.country.options [chooseSelect] .value ==" UK"){
-
美国爱国者法案是美国历史上最不爱国的行为。
Feingold-Obama''08 - 因为宪法不是历史,
这是法律。
Hey Roy,
你有什么得到了一个比较
form.country.options [chooseSelect] .value和两个OR条件将
总是评估为真。
尝试:
if(form.country.options [chooseSelect] .value ==" FR" ||
form.country.options [chooseSelect] .value ==" DE" ||
form.country.options [chooseSelect] .value ==" UK"){
谢谢,Ivan
Hey Roy,
What you''ve got there is a single comparison of
form.country.options[chooseSelect].value and two OR conditions that will
always evaluate to true.
Try:
if (form.country.options[chooseSelect].value == "FR" ||
form.country.options[chooseSelect].value == "DE" ||
form.country.options[chooseSelect].value == "UK") {
--
The USA Patriot Act is the most unpatriotic act in American history.
Feingold-Obama ''08 - Because the Constitution isn''t history,
It''s the law.
Hey Roy,
What you''ve got there is a single comparison of
form.country.options[chooseSelect].value and two OR conditions that will
always evaluate to true.
Try:
if (form.country.options[chooseSelect].value == "FR" ||
form.country.options[chooseSelect].value == "DE" ||
form.country.options[chooseSelect].value == "UK") {
Thanks, Ivan
That''s grossly inefficient, both in transmission and execution.
var Tmp = form.country.options[chooseSelect].value
if (Tmp == "FR" || Tmp == "DE" || Tmp == "UK") {
If the number of comparisons may vary, the OP can put the test strings
in an array and loop through it; that can conveniently be written as
function IsIn(Val, Arr) { var J
for (J in Arr) if (Val==Arr[J]) return true
return false }
if (IsIn(form.country.options[chooseSelect].value, ["FR", "DE", "UK"])) {
--
? John Stockton, Surrey, UK. [email protected] Turnpike v4.00 IE 4 ?
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
这篇关于字符串和OR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!