From Mervyn Bick <invalid@invalid.invalid>
Date Sun, 11 Mar 2018 20:18:24 +0200
Newsgroups dbase.getting-started

On 2018-03-11 3:52 PM, Mustansir Ghor wrote:
> Dear
> 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
> Mustansir
>   function PBRCANCEL_onClick()
>    form.eamount.value=0
>     form.cbregname.setfocus()
>   return
>   function EAMOUNT_onChange()
>          if this.value>0
>          form.pbrcancel.enabled=true
>          form.pbrsave.enabled=true
>         else
>          form.pbrcancel.enabled=false
>          form.pbrsave.enabled=false
>         endif
>    return

'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 to decide what to do depending on which
entryfield changed.

    function entryfield_onChange()
      if = 'ENTRYFIELD1'
          do something
      elseif = 'ENTRYFIELD2'
          do something else
      elseif = 'ENTRYFIELD3'
          do something different