Events are facts that occur during system implementation, from which the programmer can define actions to be performed by the program. Below is the list of possible events in Javascript, indicating the times when they may occur as well as the subject of its occurrence objects:

 

  • onload – Occurs in charge of the document. That is, only occurs in the BODY of the document;
  • onunload – occurs in the discharge (output) of the document. Also only occurs in the BODY;
  • onchange – Occurs when the object loses focus and there was a change of content. Valid for objects Text, Select and Textarea;
  • onblur – Occurs when the object loses the focus, irrespective of the existence change. Valid for objects Text, Select and Textarea;
  • onfocus – Occurs when the object receives focus. Valid for objects Text, Select and Textarea;
  • onclick – Occurs when the object receives a Click of the Mouse. Valid for Buton objects, Checkbox, Radio, Link, Reset and Submit;
  • onmouseover – Occurs when the mouse pointer passes over the object. Only valid for Link;
  • onselect – Occurs when the object is selected. Valid for Text and Textarea objects;
  • onsubmit – Occurs when a Submit type button receives a click of the mouse. Only valid for the Form.

 

JavaScript allows the programmer to write lines within a page (document) through the write method. The lines written in this way, can contain text, HTML and JavaScript expressions commands. The lines written by this method will appear on the screen point where the command is entered. For example:

 

<script>

value = 30

document.write (“My first line <br>”)

document.write (“This line appears the result of” +

(10 * 10 + value))

</ script>

 

The idea of ​​the above example is to write two lines. To prevent the two lines are written on the same line is used to HTML tag to make a line break. When writing a document is required, then the use of another essential feature: the functions.

A function is an instruction set, which should only be performed when the function is activated. The general syntax is as follows:

function functionName (parameters) {Action}

Suppose a function that aims to inform if a person is more or less old, receiving as parameter the age:

function Age (Years) {

if (Years> 17) {

alert (“Greater Age.”)

} Else {

alert (“Minor Age.”)

}

}

 

To activate this function, suppose a text box on a form, in which the old is informed, and every information, the function is triggered.

<form>

<input type = text size = 2 maxlength = 2 name = “Time” onchange = “Age (Time.value)”>

</ form>

Note that the last parameter (when the event “onchange” occurs) was the contents of the text box “Time” (property “value”) and that in the function we call “Years”. I.e., there is no correlation between the name of the variable passed and receiving variable in the function. Only the content is passed.

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.