473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Or Statement

I am implementing a conditional menu. The script below is evaluating
to see if I am on either of two specific pages. I have done it two
different way's and both are below.
Thanks in advance.

#1 This returns false all the time.

if (pageName == ('nacPartnerPage') || ('networkAccessPage')) {
nacSecondary = true;
} else {
nacSecondary = false
};

#2 This returns true all the time.
if (pageName == 'nacPartnerPage' || 'networkAccessPage') {
nacSecondary = true;
} else {
nacSecondary = false
};
Jul 21 '08 #1
5 1017
BillyZ <bi********@gmail.comwrote in news:449a2b9e-c3f5-4447-b323-
18**********@34g2000hsf.googlegroups.com:
I am implementing a conditional menu. The script below is evaluating
to see if I am on either of two specific pages. I have done it two
different way's and both are below.
Thanks in advance.

#1 This returns false all the time.

if (pageName == ('nacPartnerPage') || ('networkAccessPage')) {
nacSecondary = true;
} else {
nacSecondary = false
};

#2 This returns true all the time.
if (pageName == 'nacPartnerPage' || 'networkAccessPage') {
nacSecondary = true;
} else {
nacSecondary = false
};
you need to be more explicit

if((pageName=='nacPartnerPage') || (pageName=='networkAccessPage')) {
//blah blah blah
}
Jul 21 '08 #2
On Jul 21, 4:48*pm, BillyZ <bill.za...@gmail.comwrote:
<snip>
#1 This returns false all the time.

if (pageName == ('nacPartnerPage') || ('networkAccessPage')) {
<snip ^ ^

Unlikely. Without those two inner parentheses it might return false
all of the time. With them the above is equivalent to your second
attempt.

Jul 21 '08 #3
In article
<44**********************************@34g2000hsf.g ooglegroups.com>,
BillyZ <bi********@gmail.comwrote:
I am implementing a conditional menu. The script below is evaluating
to see if I am on either of two specific pages. I have done it two
different way's and both are below.
Thanks in advance.

#1 This returns false all the time.

if (pageName == ('nacPartnerPage') || ('networkAccessPage')) {
This is not how you do an "or". You need to write:

if ((pageName=='nacPartnerPage') || (pageName=='networkAccessPage')) {
Jul 21 '08 #4
In comp.lang.javascript message <449a2b9e-c3f5-4447-b323-18f8aa2e763d@34
g2000hsf.googlegroups.com>, Mon, 21 Jul 2008 08:48:53, BillyZ
<bi********@gmail.composted:
>if (pageName == ('nacPartnerPage') || ('networkAccessPage')) {
nacSecondary = true;
} else {
nacSecondary = false
};
Additionally, there is no need to write
if (A) B = true ; else B = false
which should be written
B = A
and is reversed by
B = !A

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF2 Op9 Sf3
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<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.
Jul 22 '08 #5
Tim Streater wrote:
BillyZ <bi********@gmail.comwrote:
>I am implementing a conditional menu. The script below is evaluating
to see if I am on either of two specific pages. I have done it two
different way's and both are below.
Thanks in advance.

#1 This returns false all the time.

if (pageName == ('nacPartnerPage') || ('networkAccessPage')) {

This is not how you do an "or". You need to write:

if ((pageName=='nacPartnerPage') || (pageName=='networkAccessPage')) {
Another, less compatible possibility[1] is

if (pageName in {nacPartnerPage: 1, networkAccessPage: 1}) {

(provided one has not augmented Object.prototype).

But the `if' statement really is superfluous here:

nacSecondary = (one_of_the_suggested_boolean_expressions);
PointedEars
___________
[1] <http://PointedEars.de/es-matrix#i>
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jul 22 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Fábio Mendes | last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with things or the python-list sent my msg to /dev/null. I couldn't find anything related in previous PEP's, so here it goes a...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
23
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.