Subject Re: LOGICAL ERROR
From Mustansir Ghor <mustan31@hotmail.com>
Date Sun, 11 Mar 2018 16:09:01 -0400
Newsgroups dbase.getting-started

Dear Mervyn

'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.

On testing,  the error is PBRCANCEL and PBRSAVE does not get disabled. I dont know why.

Best Regards
Mustansir


Mervyn Bick Wrote:

> 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 this.name to decide what to do depending on which
> entryfield changed.
>
>     function entryfield_onChange()
>       if this.name = 'ENTRYFIELD1'
>           do something
>       elseif this.name = 'ENTRYFIELD2'
>           do something else
>       elseif this.name = 'ENTRYFIELD3'
>           do something different
>       endif
>       return
>
> Mervyn.