Buy Now
Sign in

How to use elements event tab?

seppo , November 07 2018
S
seppo 85
November 07 2018 #381344
How can I setup a function call (maybe even with a parameter) from Events tab of a button-element?
I tried following:
I have button-element, as a button (not submit). In there, to Events-tab I added Actions as "Function" and to Element(s) identifier I added xyz
Then I added to same Designer tab Custom->Javascript element, and to there following lines:
function xyz() {
alert( "hello" );
}
When testing out, pressing the button did not bring the alert hello.
I also tried to add to button event xyz () as Element identifier, but that did not work either. So how can I call a function there? And can I call a function with a parameter, i.e.
xyz ("mybuttonnumber123")
Also, there is Add to and Subtract etc actions, but out of curiosity, how to use those (what do they add to or sbutract from?)
healyhatman 6.0
November 07 2018 #381347
They add or subtract the value of the field to the field you identify.
And you can just use jQuery to bind the function to the element.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums
S
seppo 85
November 07 2018 #381352
Thenk you for the explanation healyhatman.
About the binding, I actually already did that, used jQuery to bind it to click of the element. But I was curious how to do it other way round: bind an element to function. In some cases this would be more practical specifically if parameter could be used.
As I have understood, one should be able to do that: To select Function as Action as described in the original question and then just to write function name (without brackets, which would then exclude the parameter unfortunately). But this didn't work when I tested it so I either I did miss something or there is some bug with it. Most likely I am just missing some setting here.
healyhatman 6.0
November 09 2018 #381424
So just tested it out and it works for me. Select "function" as the action, put the function name without brackets in the "Element(s) identifier" field.
What have you got in your javascript code, and where did you put it? Is it first? Any errors in console?
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums