字符串和OR [英] Strings and OR
问题描述
嗨
选择任何一个国家/地区的'或''的正确语法是什么?
来自下拉列表列表?
这是我认为应该工作的,但似乎没有。
if(form.country.options [chooseSelect] .value ==" FR" ||" DE" ||" UK"){
这样做
}其他{
这样做
}
感谢您的帮助。
Roy
2006年7月21日星期五20:42:55 +0100,Roy Reed写道:
嗨
从下拉列表中选择任何一组
国家/地区的'或''的正确语法是什么?
这是我认为应该工作的,但似乎没有。
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 - 因为宪法不是历史,
这是法律。
" Ivan Marsh" < a ***** @ you.nowwrote in message
news:pa ************************* *** @ you.now ...
On Fri,2006年7月21日20:42:55 +0100,Roy Reed写道:
>嗨
从' - 或''中选择任何一个国家/地区的正确语法是什么?下面的列表?
这是我认为应该工作的,但似乎没有。
if(form.country.options [chooseSelect] .value == FR||DE||英国){
这样做
}否则{
这样做
}
感谢您的帮助。
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"){
谢谢,Ivan
JRS:在文章< pa **************************** @你。现在>,日期为星期五,21
2006年7月14:51:48远程,在新闻中看到:comp.lang.javascript,Ivan Marsh
< an *** **@you.nowposted:
>
if(form.country.options [chooseSelect] .value ==" FR" ||
form.country.options[chooseSelect].value ==" DE" ||
form.country.options [chooseSelect] .value ==" UK"){
这在传输和执行方面都非常低效。
var Tmp = form.country.options [chooseSelect] .value
if(Tmp ==" FR" || Tmp ==" DE" || Tmp ==" UK"){
如果比较的数量可能会有所不同, OP可以将测试字符串
放入一个数组中并循环遍历它;可以方便地写成
函数IsIn(Val,Arr){var J
for(J in Arr)if(Val == Arr [J ])返回true
返回false}
if(IsIn(form.country.options [chooseSelect] .value,[" FR"," DE,UK])){$>
-
?约翰斯托克顿,英国萨里。 ?@merlyn.demon.co.uk Turnpike v4.00 IE 4?
< URL:http://www.jibbering.com/faq/>? JL / RC:新闻常见问题:comp.lang.javascript
< URL:http://www.merlyn.demon.co.uk/js-index.htmjscr数学,日期,来源。
< URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/& c,常见问题项目,链接。
Hi
What''s the correct syntax for ''or'' for selecting any of a group of countries
from a drop-down list?
This is what I thought should work, but it doesn''t seem to.
if (form.country.options[chooseSelect].value == "FR" || "DE" || "UK") {
do this
} else {
do that
}
Thanks for any help.
Roy
On Fri, 21 Jul 2006 20:42:55 +0100, Roy Reed wrote:
Hi
What''s the correct syntax for ''or'' for selecting any of a group of
countries from a drop-down list?
This is what I thought should work, but it doesn''t seem to.
if (form.country.options[chooseSelect].value == "FR" || "DE" || "UK") {
do this
} else {
do that
}
Thanks for any help.
RoyHey 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.
"Ivan Marsh" <an*****@you.nowwrote in message
news:pa****************************@you.now...On Fri, 21 Jul 2006 20:42:55 +0100, Roy Reed wrote:
>Hi
What''s the correct syntax for ''or'' for selecting any of a group of
countries from a drop-down list?
This is what I thought should work, but it doesn''t seem to.
if (form.country.options[chooseSelect].value == "FR" || "DE" || "UK") {
do this
} else {
do that
}
Thanks for any help.
Roy
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
JRS: In article <pa****************************@you.now>, dated Fri, 21
Jul 2006 14:51:48 remote, seen in news:comp.lang.javascript, Ivan Marsh
<an*****@you.nowposted :>
if (form.country.options[chooseSelect].value == "FR" ||
form.country.options[chooseSelect].value == "DE" ||
form.country.options[chooseSelect].value == "UK") {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. ?@merlyn.demon.co.uk 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!