redho home | products | services

Programming Forums


Community for Java, PHP, Perl C, ASP and Python programmers

Ask your IT question here

how to handle a situation with multiple cases


Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    Programming Forums -> JavaScript forum
View previous topic :: View next topic  
Author Message
ovigo22
Enthusiastic Coder


Joined: 15 May 2006
Posts: 130
You can have as many 'else if' as you like

Reply with quote
 
kadamat
Enthusiastic Coder


Joined: 01 Jun 2006
Posts: 88
Cool... but it seems like extra keystrokes for a single situation
Reply with quote
 
ovigo22
Enthusiastic Coder


Joined: 15 May 2006
Posts: 130
Not necesarily .. switch is good for: if (X =1 ) { action } else if (X = 2) { action } else if (X = 3) {action} else {action} where the LHS of the condition is always the same
(think about multiple 'else' clasuses .. when would any but the first get executed?

Reply with quote
 
kadamat
Enthusiastic Coder


Joined: 01 Jun 2006
Posts: 88
Interesting
Reply with quote
 
AmeliaR
Enthusiastic Coder


Joined: 31 May 2006
Posts: 142
ovigo22, heh, well not to get offtrack, but for that I think a for loop would be better :-P
Reply with quote
 
ovigo22
Enthusiastic Coder


Joined: 15 May 2006
Posts: 130
Where?
Reply with quote
 
kadamat
Enthusiastic Coder


Joined: 01 Jun 2006
Posts: 88
Well, basically, I have a dropdown menu with four options. I need to set up a statement to handle all four. which would be the coolest/most elegant way to approach this?
Reply with quote
 
ovigo22
Enthusiastic Coder


Joined: 15 May 2006
Posts: 130
kadamat,switch would be as the LHS will always be the selectedIndex ..
(object full of functions == perl)

Reply with quote
 
Gladis
Enthusiastic Coder


Joined: 24 May 2006
Posts: 107
Perl must die
Reply with quote
 
kadamat
Enthusiastic Coder


Joined: 01 Jun 2006
Posts: 88
Thanks guys. So switch it is!
Reply with quote
 
Page 2 of 3 Goto page Previous  1, 2, 3  Next
Post new topic   Reply to topic    Programming Forums -> JavaScript forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group