HighDots Forums  

if - or help

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss if - or help in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
cjobes
 
Posts: n/a

Default if - or help - 10-29-2005 , 01:09 AM






Hi all,

I need to create code with multiple possible conditions like
if (x==1) or (x==2) or (x==3) {do y}
else{ do z}

this doesn't work.

Any help would be very much appreciated,

Thanks,
Claus



Reply With Quote
  #2  
Old   
T.Pastrana - 4Level
 
Posts: n/a

Default Re: if - or help - 10-29-2005 , 01:16 AM






Which language are you doing this in? It looks like your using javascript.
The or for javascript is 2 pipes ||

if (x==1) || (x==2) || (x==3) {do y}
else{ do z}



--
Regards,
...Trent Pastrana
www.fourlevel.com

Things Dreamweaver
-----------------------------------------------------------
eZeeGallery | iFrameSuite | MiniMenus | Scrollers | More...
-----------------------------------------------------------




"cjobes" <cjobes (AT) nova-tech (DOT) org> wrote

Quote:
Hi all,

I need to create code with multiple possible conditions like
if (x==1) or (x==2) or (x==3) {do y}
else{ do z}

this doesn't work.

Any help would be very much appreciated,

Thanks,
Claus




Reply With Quote
  #3  
Old   
cjobes
 
Posts: n/a

Default Re: if - or help - 10-29-2005 , 01:32 AM



Thanks Trent for the quick answer. I tried your suggestion but it doesn't
work. Here is the sample code:

if(usercode==1371215708352&&passcode==156291440) ||
(usercode==12696441744&&passcode==7658280560) {
window.location=password+".zip"}

else{
alert("password/username combination wrong")}

If I leave only one condition it works fine. As soon as I add the second,
nothing happens on the page.

Claus

"T.Pastrana - 4Level" <aaaa (AT) aaaa (DOT) com> wrote

Quote:
Which language are you doing this in? It looks like your using javascript.
The or for javascript is 2 pipes ||

if (x==1) || (x==2) || (x==3) {do y}
else{ do z}



--
Regards,
..Trent Pastrana
www.fourlevel.com

Things Dreamweaver
-----------------------------------------------------------
eZeeGallery | iFrameSuite | MiniMenus | Scrollers | More...
-----------------------------------------------------------




"cjobes" <cjobes (AT) nova-tech (DOT) org> wrote in message
news:djv06v$dem$1 (AT) forums (DOT) macromedia.com...
Hi all,

I need to create code with multiple possible conditions like
if (x==1) or (x==2) or (x==3) {do y}
else{ do z}

this doesn't work.

Any help would be very much appreciated,

Thanks,
Claus






Reply With Quote
  #4  
Old   
John Waller
 
Posts: n/a

Default Re: if - or help - 10-29-2005 , 02:15 AM



Quote:
if(usercode==1371215708352&&passcode==156291440) ||
(usercode==12696441744&&passcode==7658280560) {
window.location=password+".zip"}
There should only be one parenthesis (pair of (....) ) for the "if"
statement.

Thus, the pipes need to be inside a single parenthesis, viz:

if(usercode==1371215708352&&passcode==156291440 ||
usercode==12696441744&&passcode==7658280560) {
window.location=password+".zip"}

Note: there are lots of online resources to check your Javascript syntax
e.g.
http://oopweb.com/JavaScript/Documents/JST/VolumeFrames.html?/JavaScript/Documents/JST/Volume/c5.html


--
Regards

John Waller




Reply With Quote
  #5  
Old   
T.Pastrana - 4Level
 
Posts: n/a

Default Re: if - or help - 10-29-2005 , 02:36 AM




...or place them all in parenthesis.. just depends. In this case Johns
example would be cleaner.

if( (x==1) || (x==2) || (x==3) ){do y}
else{ do z}


--
Regards,
...Trent Pastrana
www.fourlevel.com



Quote:
There should only be one parenthesis (pair of (....) ) for the "if"
statement.

Thus, the pipes need to be inside a single parenthesis, viz:

if(usercode==1371215708352&&passcode==156291440 ||
usercode==12696441744&&passcode==7658280560) {
window.location=password+".zip"}



Reply With Quote
  #6  
Old   
John Waller
 
Posts: n/a

Default Re: if - or help - 10-29-2005 , 03:39 AM



Yup.

I was merely thinking of the master parenthesis after the "if" [ if
(.............) ] which is not present in the OP's sample code.

--
Regards

John Waller



Reply With Quote
  #7  
Old   
cjobes
 
Posts: n/a

Default Re: if - or help - 10-29-2005 , 09:38 AM



thanks for your answers, that fixed it.

Claus

"T.Pastrana - 4Level" <aaaa (AT) aaaa (DOT) com> wrote

Quote:
..or place them all in parenthesis.. just depends. In this case Johns
example would be cleaner.

if( (x==1) || (x==2) || (x==3) ){do y}
else{ do z}


--
Regards,
..Trent Pastrana
www.fourlevel.com



There should only be one parenthesis (pair of (....) ) for the "if"
statement.

Thus, the pipes need to be inside a single parenthesis, viz:

if(usercode==1371215708352&&passcode==156291440 ||
usercode==12696441744&&passcode==7658280560) {
window.location=password+".zip"}





Reply With Quote
  #8  
Old   
cjobes
 
Posts: n/a

Default Re: if - or help - 10-29-2005 , 09:48 AM



John,

Thanks for the answer and the link to the resorces. I bookmarked them for
future reference.

This code is just a temp solution. What I really like to achieve is the
following:

On occasion, clients need to download confidential zip files. I would like
to be able to send them a link in an email that has the authentication
already included so they don't have to input username and password. After
one download the link should become invalid.

Do you know of any product on the market that we could use for this? I
searched on the net but couldn't find anything

Claus
"John Waller" <johnw (AT) REMOVETHISpinnacleweb (DOT) com.au> wrote

Quote:
if(usercode==1371215708352&&passcode==156291440) ||
(usercode==12696441744&&passcode==7658280560) {
window.location=password+".zip"}

There should only be one parenthesis (pair of (....) ) for the "if"
statement.

Thus, the pipes need to be inside a single parenthesis, viz:

if(usercode==1371215708352&&passcode==156291440 ||
usercode==12696441744&&passcode==7658280560) {
window.location=password+".zip"}

Note: there are lots of online resources to check your Javascript syntax
e.g.
http://oopweb.com/JavaScript/Documents/JST/VolumeFrames.html?/JavaScript/Documents/JST/Volume/c5.html


--
Regards

John Waller




Reply With Quote
  #9  
Old   
cjobes
 
Posts: n/a

Default Re: if - or help - 10-31-2005 , 10:33 AM



Just in case someone else needs to do the same. I found an inexpensive
solution with AuthPro http://www.cgi-city.com/authpro/

They even customize the script for a very reasonable price.


"cjobes" <cjobes (AT) nova-tech (DOT) org> wrote

Quote:
John,

Thanks for the answer and the link to the resorces. I bookmarked them for
future reference.

This code is just a temp solution. What I really like to achieve is the
following:

On occasion, clients need to download confidential zip files. I would like
to be able to send them a link in an email that has the authentication
already included so they don't have to input username and password. After
one download the link should become invalid.

Do you know of any product on the market that we could use for this? I
searched on the net but couldn't find anything

Claus
"John Waller" <johnw (AT) REMOVETHISpinnacleweb (DOT) com.au> wrote in message
news:djv417$hkq$1 (AT) forums (DOT) macromedia.com...
if(usercode==1371215708352&&passcode==156291440) ||
(usercode==12696441744&&passcode==7658280560) {
window.location=password+".zip"}

There should only be one parenthesis (pair of (....) ) for the "if"
statement.

Thus, the pipes need to be inside a single parenthesis, viz:

if(usercode==1371215708352&&passcode==156291440 ||
usercode==12696441744&&passcode==7658280560) {
window.location=password+".zip"}

Note: there are lots of online resources to check your Javascript syntax
e.g.
http://oopweb.com/JavaScript/Documents/JST/VolumeFrames.html?/JavaScript/Documents/JST/Volume/c5.html


--
Regards

John Waller






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.