if...then...else...if : If « Language Basics « JavaScript DHTML






if...then...else...if

   


<html>
<head>
<title>if...then...else...if</title>
<script type="text/javascript">
var stateCode = 'MO';

if (stateCode == 'OR') {
   taxPercentage = 3.5;
} else if (stateCode == 'CA') {
   taxPercentage = 5.0;
} else if (stateCode == 'MO') {
   taxPercentage = 1.0;
} else {
   taxPercentage = 2.0;
}

document.write(taxPercentage);

</script>

</head>
<body>
</body>
</html>

   
    
    
  








Related examples in the same category

1. Determining Whether Lowercase or Uppercase Strings Are 'More Equal' Using an If Statement
2.If statement
3.Example for If...Else statement.
4.An if..else if...else statement.
5.The else Block Responds to a false Value
6.Nested if Statements
7.Deeply Nested if. . .else Constructions
8.Compare string and alert in dialog
9.Compare int value
10.Compare string value in if statement
11.Nested if statement, logic operator and regular expression
12.Is your input a Yes
13.Use if statement to check the value range
14.Nested Indented Conditional statements
15.Testing value in range