Open topic with navigation

Control - Javascript

The concept of Edit Javascript is to associate to the form fields events in Javascript, that means, for each field you can edit actions associated to its events.

Image1: Edit Javascript Interface


Selecting the object and its event, then click on the button "Edit" opening a window to edit the javascript action that will be executed when the selected event is actioned. In this screen we can type customized javascript actions or we can use default Scriptcase events, for example: nm_reload_form(); that do a reload on the form.

Image2: Interface of Javascript Edition.

Save the javascript command clicking on the button "update".

Note: Javascript language doesn't have the same behavior to each browser available in the market. If it's necessary to type a complex rotine using Javascript, we recommend to make tests in different browsers.

OnClick Example: When click on a field of the radio type can be turned on/off a series of form fields according to the selected value.

    document.F1.aux_maternity.disabled = false;
    document.F1.aux_maternity .style.background='FFFFFF'
   document.F1.aux_maternity.disabled = true;'FCEEBC'

Note: To access a field of the radio time it is necessary to use an index.

OnBlur Example:

We can define a criteria around the field “weekly_hour_job” when it loose focus.

if (document.F1.tp_folha[0].checked  && document.F1.weekly_hour_job.value > '20')
     alert("job hour above the allowed.");
     document.F1.weekly_hour_job.value = "";

onChange examples:

When modify the “Salary” of an employee and go out of the field, will occur an “onChange”, in this moment we use advantage to check if the “position” is “gardener”.

if (document.F1.salary.value > 5000.00 && document.F1.position.value == 'gardener'){

alert('when you grow i want to be a gardener');


After informing the value of the purchase and select the modality of the payment in an object of the “Select: type payment_way”, the javascript code below calculates the value of the parcel.

 if(document.F1.payway[document.F1.payment_way.selectedIndex].text == 'avista')
      document.F1.parcelvalue.value = document.F1.purchasevalue.value;
if (document.F1.payway[document.F1.payment_way.selectedIndex].text == '30/60')
      document.F1.parcelvalue.value = document.F1.purchasevalue.value / 2;
if (document.F1.payway [document.F1.payment_way.selectedIndex].text == '30/60/90')
      document.F1.parcelvalue.value = document.F1.purchasevalue.value / 3;

onMouseOver Example:

We can trade the stile (background color, font color, etc.) when the mouse is over the field. = "0FFCCA"

onMouseOut example:

Set a background color when the mouse loose focus of the field. = "FFFFFF"