Several js in one OnChange Skript

Hello,

I have two js Skript in my js/common installation.

For example:

One.js

var One = One || {};

One.exec = function () {

document.EntryForm["vpos_preis"].value = 99;

]
 

Two.js

var two = Two || {};

Two.exec = function () {

document.EntryForm["vpos_netto"].value = document.EntryForm["vpos_preis"].value;

]

Both functions where called in an onchange skript directly behind each other.

My problem is that in the first script the value of "preis" is changed to 99.

But in the second script I could not read this new value until all scripts are executed.

How can I read the new value in the second script?

Thank you!

  • 0

    I think you will need to explain a little more about what you are trying to achieve.

    I have made the assumption that you are using a custom script within the folder

    C:\Program Files (x86)\Sage\CRM\CRM\WWWRoot\js\custom

  • 0 in reply to Sage CRM

    Yes, you are right.

    I have to use two scrips.

    One is used by some fields in "onchange" and change only the value of vpos_preis.

    Some other fields has to change the value of vpos_preis and do addition things directly behind.

    This is the reason why these scripts are separated.

    But when I call both functions in an "onchange" script the values are not calculate correctly.

    For example I put this in an "onChange" of one field:

    One.exec();

    Two.exec();

    In this case the call of Two.exec() will not calculate with the value of 99 for vpos_preis.

  • 0 in reply to Nunzio Piazzolla

    I think you may be making things to complex.

    Consider this simple function

    function checkCase(x)
    {
    x = x.toLowerCase();
    return x;
    }

    This function in the Custom Script would be available for all client side code.  It will accept a string variable 'x' and makes it lower case and returns the new version of the string.  In JavaScript, the this keyword refers to an object.   In the context of the script the 'object' is the field.

    It would be used in a onChange script like this

    this.value = checkCase(this.value);