Execute javascript function from a Button

tshirley 29 Dec, 2018
Hello,

In the Events tab for a Button, I was looking for a "Function" action so that I can execute a JS function from a button press.

I was a bit surprised to find that the option is not there in the Actions dropdown.

Is there a way to achieve the same result? Basically I want to reset several form fields using a Javascript function if a button is clicked. I can achieve the same result in another way but it is not so visually effective and it would be very useful if a button can be used for this.

Cheers
healyhatman 29 Dec, 2018
Of course it can is it not there? On click? Function? Should be there.

If not just bind it as usual with jQuery
tshirley 29 Dec, 2018
Well, no..

Have a look.. the option "Function" is not in the Actions dropdown for a Button object.

And.. um.. how do I "bind it as usual...?" I have never done anything like that..

Cheers

Tim
GreyHead 29 Dec, 2018
Hi Tim,

Please see the jQuery docs here for an example.

Bob
tshirley 29 Dec, 2018
OK, got it🙂

Thanks heaps..

But I am puzzled why the choice to execute a function is not present in the Action dropdown for a button. It seems a natural thing to want to do with a button, and it is obviously possible🙂

Anyway no matter. Problem solved.

Cheers

Tim
GreyHead 29 Dec, 2018
Hi Tim,

I see Function in the Button element Actions list - though you have to scroll down to get there.

Bob
tshirley 29 Dec, 2018
Hi Bob,

On the button Actions I see the following:

Enable
Disable
Show
Hide
Enable Validation
Disable Validation
Add to
Subtract from
Multiply with

And that is all. No Function or Reload.

Perhaps I need an upgrade or something?

Cheers

Tim
GreyHead 29 Dec, 2018
Answer
1 Likes
Hi Tim,

Could be . . . I have v6.0.20 with

Enable
Disable
Show
Hide
Disable Validation
Enable Validation
Reload
Function
Add to
Subtract from
Multiply with

Bob
tshirley 29 Dec, 2018
HI Bob and all,

Yes, that fixed the problem - I now see the two missing options.

However, not all is bad - I have learned how to "bind" actions with jQuery, so I am no longer limited to the Actions list provided, and that will certainly help.

Many thanks to you and to healyhatman for pointing me in the right direction.

Cheers

Tim
This topic is locked and no more replies can be posted.