Page 1 of 1

Display element onLoad event not firing

Posted: Thu Sep 20, 2018 4:21 pm
by tonyd
I have a Display object that shows the result of a SQL calculation. I tried setting the Custom Code section to run this code on the Load (onload) event:

Code: Select all

if (parseFloat($("#my_object_id").val()) > 0) {
    $("#my_object_id").css("color", "red");
} else {
    $("#my_object_id").css("color","black");
}
However, the onLoad event never seems to set this off. I have checked to see that my code works by setting it to fire under the onBlur event, which all works fine.

Any idea why the onLoad event doesn't fire for this object? Does it have anything to do with the nuLoad() function?

Re: Display element onLoad event not firing

Posted: Fri Sep 21, 2018 8:16 am
by admin
TonyD,

I'm not sure what you mean by...
the onLoad event
All you need to do is put it in the Javascript section of the Form you are opening.


Steven

Re: Display element onLoad event not firing

Posted: Fri Sep 21, 2018 10:51 am
by tonyd
Steven,

That is exactly what I did
Capture.JPG
Unfortunately, the Javascript never fires using "onload" as the trigger, but it does if I use "onblur" and then click away from the object.

Re: Display element onLoad event not firing

Posted: Fri Sep 21, 2018 11:30 am
by toms
Place the code in your form's Javascript area:

Code: Select all

if(nuFormType() == 'edit') {
  
    if(parseFloat($("#my_object_id").val()) > 0) {
        $("#my_object_id").css("color", "red");
    } else {
        $("#my_object_id").css("color", "black");
    }
  
}

Re: Display element onLoad event not firing

Posted: Fri Sep 21, 2018 9:23 pm
by tonyd
Thank you Toms. It worked like a champ.

Re: Display element onLoad event not firing

Posted: Fri Sep 21, 2018 11:24 pm
by admin
.