Book Section
-----
TY JavaScript 3rd Ed.
Teach Yourself JS 1.5
Teach Yourself DHTML
Teach Yourself JS 1.3
LLWW: JavaScript

General Section
-----
Discussion Forum
Articles / Tips
JavaScript Links
About the Author
Privacy Policy
Contact Me



Other Sites
-----
Website Workshop
JavaScript Weblog

JavaScript Workshop Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
conditional statements

 
Post new topic   Reply to topic    JSWorkshop Forum Index -> JavaScript
View previous topic :: View next topic  
Author Message
JaccTrippa
New member
New member


Joined: 18 Dec 2010
Posts: 3
Location: US

PostPosted: Wed Dec 22, 2010 10:01 am    Post subject: conditional statements Reply with quote

hello all. just kind of curious. how do i make a switch statement with variables that can be a huge range of numbers? like for instance, say that i wanted to make a any number over 100 cause one thing to happen. then i wanted another thing to happen if the number was less than 100? Can you please help me with my logic?!?! This is as far as i have gotten:

var num = "";
var output = "";


switch(num)
{
case 1:
output = "";
break;

case 2:
output = "";
break;

default:
output = "sucks, figure it out";
}

Back to top
View user's profile Send private message
thecodewall
Member
Member


Joined: 26 Dec 2010
Posts: 10

PostPosted: Sun Dec 26, 2010 8:31 am    Post subject: Reply with quote

Code:
<html>
<body>
<script type="text/javascript">
var num = 2;

switch(num)
{
case 1:
document.write("A");
break;

case 2:
document.write("B");
break;

default:
document.write("sucks, figure it out");
}
</script>
</body>
</html>


http://codewall.blogspot.com


Last edited by thecodewall on Tue Jan 04, 2011 10:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
artguytom
New member
New member


Joined: 15 Dec 2010
Posts: 4

PostPosted: Sun Dec 26, 2010 2:21 pm    Post subject: Why not a simple conditional? Reply with quote

I'm kind of a beginner too, but why a switch statement?

Why not just a conditional?
Code:

<html>
<body>
<script type="text/javascript">
var num = prompt("Gimme a number.");
if(num > 100) {
   document.write(num + " is a pretty big number.");
} else {
   document.write(num + " is a smaller number.");
}
</script>
</body>
</html>
Back to top
View user's profile Send private message
JaccTrippa
New member
New member


Joined: 18 Dec 2010
Posts: 3
Location: US

PostPosted: Mon Dec 27, 2010 6:05 am    Post subject: Reply with quote

you guys are smart and awesome. thanks. artguytom i require your assistance in another manner. can you email me terrelstinnett37@yahoo.com please if you have time.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    JSWorkshop Forum Index -> JavaScript All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
(c) 1997-2002 Starling Technologies and Michael Moncur. Portions (c) Sams Publishing.