if...then...else...if : If « Statement « JavaScript Tutorial






<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>








3.2.If
3.2.1.Conditionals
3.2.2.if...else
3.2.3.Use if statement to compare the numbers
3.2.4.Use if/else to check the returning value from a confirm dialog
3.2.5.Use if statement to check the returning value from a confirm dialog
3.2.6.Nested if statement
3.2.7.if...then...else...if