Welcome to Bucaro TecHelp!

Bucaro TecHelp
HTTPS Encryption not required because no account numbers or
personal information is ever requested or accepted by this site

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Java Script confirm Message Box

In Java Script programming, there are many occasions when you need to display a short message to the user, or request a bit of information from the user. In these instances, you can use a message box.

Java Script provides three types of message boxes, the alert, confirm, and prompt. They are all easy to create and use.

• These message boxes are "modal" dialog boxes, meaning that program flow halts while the message box is visible. The user is unable to use the page that spawned the message box until they click on a button to close the message box. This may be disruptive to the user. You can also design your own custom message box, which you may or may not choose to make modal.

Confirm message box

A confirm presents a message with an [OK] button and a [Cancel] button. If the user clicks on the [OK] button, the confirm dialog box returns true. If the user clicks on the [Cancel] button, the confirm dialog box returns false. Clicking on either button dismisses the dialog box. Example code to create a confirm message box is shown below.

if(confirm("Message"))
{
  alert("User clicked [OK] button");
}
else
{
  alert("User clicked [Cancel] button");
}

A confirm message box can be used to ask the user if a certain function should be performed.

if(confirm("Perform function?"))
{
  // Code to perform function
}

More Java Script Code:
• The do/while Loop
• The Navigator Object
• The for Loop
• Cookie Power Made Easy
• Remove Blank Spaces From Ends of a String
• Include a Quote Character in a String
• Java Script Number Object
• JavaScript Character Escape Sequences
• Java Script Math.tan Method
• The continue Statement

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro


Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2024 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268