Connect with Facebook   
    Home  |   Learn AJAX  |   Forum  |    Register  |    Submit Resource  |   Submit Article   |   Contact Us
 

JavaScript

Home JavaScript

Prompt, Alert and Confirm

Category: JavaScript   |   Comments (0)

Sometimes, the small functions in an Ajax based application are the ones that are most important. But even in a massive application, the small things should never be ignored. They might be considered as a leak where the point of attack will commence. Without securing the small things, your application might be destroyed without even knowing it.


Sponsored Links
 

 


In this article, we take a look at three popular functions not only in JavaScript and Ajax but also in other programming languages: prompt, alert and confirm. These three functions will increase the interaction of the application. These functions are lightweight which requires little resources from the developer and the user.


The Prompt Function

As the name suggest, the prompt function will result to a pop-up message that will inform a user of anything the developer wishes to do.


For example, the developer wants to ask the user to “sign” the given data through a prompt. The code will go this way:


var popup=window.prompt("Initials Please")


In this code, a message will pop-up asking the user to enter initials to make sure that the interaction is certified. Additional functions related to the (popup) variable could be exploited such as changes in the window.


The Alert Function

This function is a little bit simpler compared to prompt function. It does nothing else other than to inform a person about the action. The code goes this way:


window.alert("Hi!")


As soon as the user clicks on the box where the function is attached, a new window will pop-up saying “Hi!” There are thousands of reasons why you need to add an alert function. This could be used to inform the user that the entered data is not correct or just to warn the user that something drastic is about to happen in the online application.


The Confirm Function

This form of function is a little bit tricky compared previous functions. The function looks like this:


var ask=window.confirm("Please Confirm")
if (ask)
window.alert("Ok")
else
window.alert("Select Another Function")


When the application reaches this function, it will ask the user to select from the options. If the selected option is “OK” then it will prompt “Ok” or anything the developer wishes.


The key to proper implementation of confirm function is to align the variable properly. If the variable is according to the (if) function then everything else would be a lot easier.


Combination of Functions

These three functions could be combined depending on the need of developers. For example, they can use the prompt function and the alert function to create a variation of the confirm function.


Remember the prompt could be used to ask a couple of questions to the user but it will not provide any response. The alert function could be used as a response to the user. Although the options will be limited (still the same alert even with different responses), it’s a good way to interact with your users.



Sponsored Links
 

 

Prompt, alert and confirm are three small but highly useful functions in an Ajax based application. Use them wisely to provide eye catching and interactive online applications.



Read Next: Deep Nesting


 
Post Your Comment
Members - Please Click here Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification:
 
 Subscribe    

Post Your Comment via FaceBook

Connect with Facebook



 
Comments
 
 
 
 

Sponsored Links

 

Copyright © 2005 - 2010 AjaxWith.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape