Inicio > Ajax, English, JavaScript, Oracle, Oracle APEX > Automatic change items tabular form (Ajax)

Automatic change items tabular form (Ajax)

In this post I will try to explain something that is apparently very simple, but may be complicated as we are doing
development. The idea is to modify certain fields in a tabular form, when I change the value of another field the same form.

Suppose we have a screen that we have the following tabular form.

Now we raise is what we will do: “We would like that when we change the name, it automatically completes the group, num 01, the num num 02 and 03 with a series of preset values”

For them, sure there are many possibilities, but we will use one that we believe is very simple and easy to implement. We will make use of our great ally, the JavaScript.

The first thing we do is create a field name associated with the action on the onChange event. To do this we must edit the field in the report and paragraph Element Attributes located in the region Column Attributes must put a code like this:

onChange=’myFunction(this);’

With this we will get each time you change the name field value, to run our JavaScript function to which we have named myFunction. The rest of the process is more work than the actual APEX JavaScript. We must make the development of the function we want to modify the field values ??and insert it into that part to the definition of JavaScript in the page (Page -> Edit Page -> HTML Header and Body Attributes). Here is where we enter a code similar to what I show below.

function myFunction (obj) {

// Valor para GRUPO
document.getElementById(‘f05_’ + obj.id.substr(4,4)).value = ‘GRUPO’;

// Valor para NOM 01
document.getElementById(‘f06_’ + obj.id.substr(4,4)).value = 01;

// Valor para NOM 02
document.getElementById(‘f07_’ + obj.id.substr(4,4)).value = 02;

// Valor para NOM 03
document.getElementById(‘f07_’ + obj.id.substr(4,4)).value = 03;

}

With this simple JavaScript function get any change in the values ??of each of the fields you want, directly attacking the DOM of each of the objects that compose the tabular form.

I hope you find it useful and if you have any doubts, do not hesitate to contact us so we help you in everything you need.

  1. Aún no hay comentarios.
  1. No trackbacks yet.

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: