Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

JavaScript Confirm Box

By Exforsys | on April 25, 2007 |
JavaScript Tutorial

JavaScript Confirm Box

In the previous section of this tutorial JavaScript Alert Box, we discussed about alert boxes. In this section, you will learn about JavaScript confirm box and prompt box.

Confirm Box:

The confirm box is a box that pops up with both an OK and a Cancel button. The confirm box is used to verify acceptance from the user. If the user accepts, then the user presses the OK button and the confirm box returns with a true value. If the user rejects with the Cancel button, then the confirm box returns false value.

General syntax for a confirm box is

confirm (“textmessage”)

A simple confirm box example:


<
html>
   <body>
    
<script type="text/javascript">
        if (confirm("Wish to accept or Cancel"))
        {         

           alert ("Agreed and hence True value returned")

        }

        else

        {         

           alert ("Not Agree and hence False value returned")

        }

      </script>
   </body>
</html>

In the above example, the conditional statement if…else is used and the alert box and the confirm box are written together.

Output of the above script as produced in a HTML page is shown below:

The confirm box pops up with the message:

Wish to accept or Cancel

Showing two buttons (OK and Cancel) that the user can choose from. If the user presses OK in the confirm box then the value returned would be true, executing the if block of statements. This results in the alert box popping up with the message.

Agreed and hence true value returned.

If the user presses the Cancel button in the confirm box then the value returned would be false, executing the else block of statements. This results in the alert box popping up with the message

Not Agreed and hence false value returned

Prompt Box:

The prompt box is used when a user’s input value is desired before entering a page. The prompt box pops up with two buttons (OK and Cancel). If the user presses OK then the prompt box returns with the value entered by user but if the user presses the Cancel button then the prompt box returns with a null value.

General syntax of prompt box is as follows:

prompt(“textmessage”,”value_default”)

A simple prompt box example:


<
html>
   <body>
    
<script type="text/javascript">
        name = prompt ("Input the Training Company Name","Exforsys")
    </script>
   </body>
</html>

 

Output of the above script as produced in a HTML page is shown below:

In the above example, the default value is stored with value Exforsys and the prompt box pops up with the message Input the Training Company Name with a default value as Exforsys and two buttons (OK and Cancel). When the user presses the OK button, the value Exforsys is returned by prompt box, which is stored in the variable name. If the user presses Cancel, then null value is retuned by the prompt box.

« « JavaScript Conditional Statements Part 2
Advantages and Disadvantages of Web 2.0 » »

Author Description

Avatar

Editorial Team at Exforsys is a team of IT Consulting and Training team led by Chandra Vennapoosa.

Free Training

RSSSubscribe 401 Followers
  • Popular
  • Recent
  • JavaScript Conditional Statements Part 1

    April 24, 2007 - 0 Comment
  • JavaScript Document Object Methods Part II

    August 7, 2007 - 0 Comment
  • Passing values to JavaScript Function

    June 5, 2007 - 0 Comment
  • JavaScript Event Object

    May 20, 2007 - 0 Comment
  • JavaScript Array Object Methods – Part II

    July 17, 2007 - 0 Comment
  • JavaScript Conditional Statements Part 2

    April 24, 2007 - 0 Comment
  • JavaScript History Object Properties and Methods

    August 5, 2007 - 0 Comment
  • JavaScript Two Dimensional Arrays

    June 7, 2007 - 0 Comment
  • JavaScript Event Object Properties and Methods

    June 9, 2007 - 0 Comment
  • JavaScript Introduction

    April 5, 2007 - 0 Comment
  • JavaScript Objects

    August 12, 2007 - 0 Comment
  • JavaScript String Object

    August 12, 2007 - 0 Comment
  • JavaScript Date Object

    August 12, 2007 - 0 Comment
  • JavaScript Math Object

    August 9, 2007 - 0 Comment
  • JavaScript Windows Object Properties Part II

    August 9, 2007 - 0 Comment
  • JavaScript Windows Object Properties Part I

    August 8, 2007 - 0 Comment
  • JavaScript Window Object Timeout Methods

    August 8, 2007 - 0 Comment
  • JavaScript Document Object Methods Part II

    August 7, 2007 - 0 Comment
  • JavaScript Document Object Methods Part I

    August 5, 2007 - 0 Comment
  • JavaScript History Object Properties and Methods

    August 5, 2007 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • JavaScript Objects
  • JavaScript String Object
  • JavaScript Date Object
  • JavaScript Math Object
  • JavaScript Windows Object Properties Part II

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2022. All Rights Reserved.IT Training and Consulting
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy
Necessary Always Enabled