|
switch-case statement |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko"> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
<head> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
<title> switch-case statement 1 </title> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
</head> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
<body> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
<script type="text/javascript"> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
// syntax used when values do not overlap |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
//<!CDATA[ |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
var menu=1; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
switch(menu){ |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
case 1:won=1000; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
break; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
case 2:won=2000; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
break; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
case 3:won=3000; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
break; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
default:won=4000; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
break; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
document.write(won); |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
//]]]]> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
</script> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
</body> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
</html>switch-case statement 2) A script that reacts to a specific value entered by the user or a value set initially. The example below is the second one, so it uses a bit more application. 1. Ask for the blood type. (=prompt) 2. follow bl in switch(bl), and the result is derived based on the case the user entered.
|
← Back to feed
Renewal·서른의 생활코딩
Sample Source 2) JavaScript Basics (Switch-Case Statement)
This English version was translated by Claude.
