Confirm Boxes in JavaScript


It is easy to create a confirm box in JavaScript. Suddenly my mind is in a ferment over how these boxes might be used on webpages. Of course, just having had bean soup, I first thought of creating a confirm box for my famous lima bean soup recipe. It asks the reader if they are ready to rumble. If yes, then it says that they have been eating too much bean soup. If “cancel”, then there is an alert box telling them that they need to eat some. Yes, just another example of my juvenile sense of humor.

Anyway, here is the code I placed in the header:

<script type=”text/javascript”>
function confirmfunction()
{
var rumble = confirm(“Are you ready to rumble?”);
if (rumble==true)
{
alert(“You have been eating too much bean soup!”);
}
else
{
alert(“You need to have yourself a bowl of bean soup!”);
}
}
</script>

With the body tag looking like this:

<body onload=”confirmfunction()”>

  1. No comments yet.

You must be logged in to post a comment.