[Javascript] Help please

Filipiak, Bob (Contractor) filipiab at atsc.army.mil
Thu Jan 24 13:09:19 CST 2002


In the switch( expression){ CASE ...: CASE ...: } syntax, the expression can
evaluate to any string or number value. It is singular. Consequently,
switch(sport, times) is invalid because it does not evaluate to a single
value/string.
 

Bob Filipiak 


-----Original Message-----
From: Sherwithme1 at cs.com [mailto:Sherwithme1 at cs.com]
Sent: Thursday, January 24, 2002 1:52 PM
To: javascript at latech.edu
Subject: [Javascript] Help please


Could you tell what I am doing wrong? I want both variables to be evaluated
using the switch statement. Why is it not working? 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 

<html> 
<head> 
<title>Switch</title> 
<div align = "center"> 
</head> 
<body> 
<script language = "JavaScript1.2" type = "text/javascript"> 
var sport, times= prompt("Which sport like to do best, skiing, skydiving,
basketball, or football?", "Please choose one from the list") 
prompt("How often do you do this, daily, weekly, or monthly?", "Please
choose one from the list") 
switch(sport, times){ 

case "skiing" && "daily": 
document.write("You choose to ski daily"); 
break; 
case "skiing" && "weekly": 
document.write("You choose to ski weekly"); 
break; 
case "skiing" && "monthly": 
document.write("You choose to ski monthly"); 
break; 
case"skydiving" && "daily": 
document.write("You choose to go skydiving daily"); 
break; 
case"skydiving" && "weekly": 
document.write("You choose to go skydiving weekly"); 
break; 
case"skydiving" && "monthly": 
document.write("You choose to go skydiving monthly"); 
break; 
case"basketball" && "daily": 
document.write("You choose to play basketball daily"); 
break; 
case"basketball" && "weekly": 
document.write("You choose to play basketball weekly"); 
break; 
case"basketball" && "monthly": 
document.write("You choose to play basketball monthly"); 
break; 
case"football" && "daily": 
document.write("You choose to play football daily"); 
break; 
case"football" && "weekly": 
document.write("You choose to play football weekly"); 
break; 
case"football" && "monthly": 
document.write("You choose to play football monthly"); 
break; 
default: 
document.write("You didnt answer the questions!"); 
break; 
} 


</script> 
</div> 
</body> 
</html> 
Thanks for your help 
Totally confused 
Sheryl 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20020124/8672276a/attachment.htm>


More information about the Javascript mailing list