Sullivan Market

a web based full-circle development system



My JavaScript Tutorials - Switch Statements

Here's the Javascript:

<script language="JavaScript">
<!--
function jsPrompt()
{
var unicorn = prompt("How many feet does a unicorn have?","")
switch(unicorn)
{
case '1': alert("No, one horn, four feet"); break
case '4': alert("correct, four feet, one horn"); break
default: alert("No, one horn, four feet");
}
}

// -->
</script>
<a href="javascript:jsPrompt()">A question if you don't mind.</a>

Try it out:

A question if you don't mind.

Note: You can see the syntax for Prompt on our alert page.

Back To JavaScript Tutorials

©2012 SullivanMarket.com