Global GuideLine Home HTML Tutorial JavaScript Tutorial SQL Tutorial CSS Tutorial SEO Tutorial XML Tutorial XSLT Tutorial Articles Tutorial Interview Questions and Answers Guide Jobs GuideLine Bookmark With Google Bookmark With Yahoo Bookmark With FaceBook Bookmark With Live Follow @GlobalGuideLine on Twitter Bookmark Global GuideLine
Confirmation Boxes using JavaScript, JavaScript Tutorial, Global Guide Line Technology.
Bookmark this webpage. Bookmark: Confirmation Boxes using JavaScript, JavaScript Tutorial Global Guideline is UNITED STATES's favorite website

      Home                    

Basic JavaScript Guide.
 JScript Introduction.            
 JScript Why?                       
 JScript Recognitions.          
 JScript onMouseover.         
 JScript with Buttons.           
 JScript Alerts.                     
 JScript Variables.               
 JScript Operators.               
 JScript Functions.               
 JScript Prompts.                 
 JScript Conditions.             
 JScript Validations.            
 JScript Confirmation Boxe
 JScript Browser Detection.  
 JScript Redirection.            
 JScript on Links.                 
 JScript Switch.                    
 JScript Loops.                     
 JScript Events.                    
 JScript Exception Handling.
 JScript Reserve Characters. 
 JScript with Objects.            
 JScript Math Object.           
 JScript using Dates.             
 JScript using String.            
 JScript using Arrays.            
 JScript Operations.              
 JScript Handling Cookies.   
 JScript in Mapping.             
 JScript Time Out.                
 JScript Summary.                

Learn JavaScript with Examples
Learn JavaScript with hundred of short examples with code and output.
Complete_JScript_Examples.php

JScript Interview Questions & Answers
Learn JavaScript by thousands of Interview Questions & Answers.
JavaScriptQuestions/index.php

JavaScript Tutorial >> Confirmation Boxes using JavaScript.


     Back             Next     





JavaScript confirmation boxes can be a handy way to give our visitors an alternative of whether or not an action is performed. JavaScript confirmation box will pop up much like an JavaScript alerts, but will allow the viewer to press an "OK" button or "Cancel" button. Here is the necessary command for creating a confirmation box.

Syntax for JavaScript Confirmation Boxes

confirm("JavaScript Confirmation Box statement, Press OK or Cancel");

The difficulty is, if we use just that it isn't very handy to reuse of capture the user action. The JavaScript confirmation boxes will return a value of True or False, so this is what we must use to make use of the JavaScript confirmation box. An easy way to get the value for later use is to assign it to a JavaScript variable, like the below code for JavaScript Confirmation box capturing the returned value. 

Capturing JavaScript Confirmation Response

var respOfConfirmation= confirm("Press OK or Cancel.....");

Now, here we can use the respOfConfirmation a JavaScript variable to examine what the visitor responding to this JavaScript alert.  Here action is depending on the value the JavaScript confirmation box returned on behalf of user action. We can do this with an if/else statement block like below code we are handling JavaScript Confirmation response using JavaScript conditional statement [if/else].

Handling JavaScript Confirmation Response using if/else

<SCRIPT language="JavaScript">
function Confirm_Ok_Cancel()
{
 var respConfirmation= confirm("Please Press Ok or Cancel...");
 if (respConfirmation== true)
 {
   alert("Hi you pressed Ok, I got it with JavaScript Confirmation response...");
 }
 else
 {
  alert("Hi you Pressed Cancel, Have a nice tour of JavaScript Tutorial");
  }
}
</SCRIPT>

Now use the above JavaScript Confirmation box, its capturing and handling code in the body of our web page like this.

<body onLoad="Confirm_Ok_Cancel()">

Out put of JavaScript Confirmation Boxes.

When the page will be loaded or refreshed then visitor can have the below screen shore in front of him.



     Back             Next     
 

JavaScript Alert, Confirmation and Prompt Boxes Examples



In order to link this page as Reference, click on below text area and pres (CTRL-C) to copy the code in clipboard or pres right click then copy the following lines after that past into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code:

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright © 2005-2006 www.globalguideline.com All rights reserved. Join Global Guide Line community. 480 visitors are online now