Re: Javascript Logic - Brain Freeze

by "Srinivasan Ramakrishnan" <srinivar(at)md3.vsnl.net.in>

 Date:  Tue, 26 Sep 2000 12:35:27 +0530
 To:  "Cyanide _7" <leo7278(at)hotmail.com>
 Cc:  <hwg-languages(at)hwg.org>, <MEovino(at)Estes-Express.com>
 References:  hotmail
  todo: View Thread, Original
Well, I agree that & and && will work the same here, but I have a doubt
regarding the operator precedence of & over ==

Maybe a ( ) would help? Sorry I'm short of time or I'd try.
ex:

if((document.forms[0].Class1.value == "") & (document.forms[0].Desc1.value
== "")){

-Srini
----- Original Message -----
From: Cyanide _7 <leo7278(at)hotmail.com>
To: <srinivar(at)md3.vsnl.net.in>
Cc: <hwg-languages(at)hwg.org>
Sent: Tuesday, September 26, 2000 4:15 AM
Subject: Re: Javascript Logic - Brain Freeze


> i thought the same thing, but when you think about it, true evaluates to 1
> and false to 0. i tried a few things with bitwise and this example:
>
> (true & true) => 1 => true
> (false & true) => 0 => false
> (false & false) => 0 => false
>
> as far as this example goes, & and && should produce the same results. i'm
> inclined to think the problem exists elsewhere? - Cyanide_7
>
> >At first glance the problem exists beause you are using a bitwise & and
not
> >a &&.
> >
> >
> >-Srini
> >----- Original Message -----
> >From: <MEovino(at)Estes-Express.com>
> >To: <hwg-languages(at)hwg.org>
> >Sent: Monday, September 25, 2000 9:26 PM
> >Subject: Javascript Logic - Brain Freeze
> >
> >
> > >
> > > I know this should be obvious, but it's not to me.  In a validation
> >script,
> > > I want to make sure that one of two fields is filled.  The following
is
> > > part of a much larger script.
> > >
> > > <snip>
> > > else if(document.forms[0].Class1.value == "" &
> >document.forms[0].Desc1.value == ""){
> > >      msg="Please enter a valid class or description";
> > >      msgflag="true";
> > >                 document.forms[0].Class1.focus()
> > >      }
> > > </snip>
> > >
> > > What this looks like, in my disordered mind, is that if the value of
> >both
> > > fields is "", then do what's in the brackets.  Otherwise, move to the
> >next
> > > statement.  However, if I leave either one blank, it shows the message
> >(msg
> > > is used in an alert box, shown when the msgflag is set to true).  What
> >am
> >I
> > > doing wrong?
> > >
> > > Thanks in advance!
> > > Mike E.
> > >
> > >
> > >
> > >
> >
>
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.
>
>

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA