||Re: LOGICAL ERROR
Mervyn Bick <firstname.lastname@example.org>
||Sun, 11 Mar 2018 20:18:24 +0200
On 2018-03-11 3:52 PM, Mustansir Ghor wrote:
> I seem to get confused many times use of 'this' object. When following PBRCANCEL_onclick() is executed, there is change in value of form.eamount. Therefore function Eamount-Onchange() will execute. On its execution what will 'this' refer to ?
> Best Regards
> function PBRCANCEL_onClick()
> function EAMOUNT_onChange()
> if this.value>0
'This' is form.eamont in this case. The event handler is executed by
form.eamont when the value changed. As you use PBRCANCEL to save 0 to
form.eamont the event handler will immediately disable PBRCANCEL and
PBRSAVE. These pushbuttons are disabled until, say, the edit pushbutton
is pressed which would execute code to enable them again.
If you had executed the event handler from, say, the form's onOpen event
handler 'this' would be the form. The form doesn't have a value
property so if it doesn't have a user-defined value property there would
be an error.
'This' in a function is always the object which executes the function.
If, for instance, instead of assigning different onChange event handlers
to several entryfields you assign the same event handler to each
entryfield you can use this.name to decide what to do depending on which
if this.name = 'ENTRYFIELD1'
elseif this.name = 'ENTRYFIELD2'
do something else
elseif this.name = 'ENTRYFIELD3'
do something different