In JavaScript, the programmer has some interesting options regarding native feature, some of them are very helpful especially for simple functions of daily interaction with the user that some pages may need. The command ALERT, CONFIRM AND PROMPT are clear examples of this type of resource.

ALERT

The dialog ALERT serves to show an information and only has a button to close. This feature is often used to display messages to the user possible, especially in cases where there are errors in filling out forms or information processing. See below for an example of code ALERT:

<SCRIPT LANGUAGE=”javaScript” type=”text/javaScript”>
alert (“Hello, this is an ALERT box.”)
</ SCRIPT>

CONFIRM

Unlike ALERT, CONFIRM the box returns a Boolean value (true or false) for that particular action is performed. Using the buttons “OK” and “Cancel” certain action can be performed, just that an IF is created validating the information returned from CONFIRM, check below a practical example:

<SCRIPT LANGUAGE=”javaScript” type=”text/javaScript”>
var = return confirm(“Choose an option.”);

if (back) {
alert (“You clicked on OK button!”);
}else {
alert (“You clicked on Cancel button”);
}
</ SCRIPT>

PROMPT

This dialog box is used to test more code blocks, from a data entry user can perform certain processing. This feature has been replaced by text fields, so you will hardly use it on a daily basis, but nevertheless it is important to know what this feature does. Check out the example:

<SCRIPT LANGUAGE=”JavaScript” type=”text/JavaScript”>
var name;
do {
name = prompt (“What is your name?”);
} While (name == null | | name == “”);
alert (“Your name is” + name);
</ SCRIPT>

javascript

There are countless resources that JavaScript language features, so it is important to understand well on its operation. Often a problem can be solved with a simple method exists in the native language.

Want to test our examples and still learning how to use other features of a web development tool more powerful in the world? Then download the free version now Scriptcase and meet a world of possibilities.

You might also like…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.