8 years ago
Topic

Hi,

   I want calling a JS function on trigger. For exemple, I have added into a form a free button with following parameter (as described into tuto)

Into custom attribute I add:

onclick="myfunction(this)";

Into Scrip JS I add very simple function:

function myfunction()
{
alert("coucou");
}

When I click on button, nothing append

Thank you to help me.

Get a VIP membership
4229 Posts
Kadministrator
8 years ago
5
Level 1

Problem is that by usign Script js your function gets wrapped in anonymous function like bellow, so function is undefined on the global scope, you need to use

http://www.seblod.com/products/1854

or add it to the template directly

jQuery(document).ready(function($){function myfunction()
{

alert("coucou");

}});
8 years ago
4
Level 2

Hi,

I understand your answer, I have added JS code with Code Pack plug-ins. In the head section of html page, I have:

jQuery(document).ready(function($){ function myfunction() { alert("coucou"); } });

Now I want to call this function with a free button. Normaly the JS code is called by:

<button type="submit" name="btn-coucou" id="btn-coucou" onclick="myfunction();">

Into SEBLOD, how I can make my button calls function 'myfunction'

Thank you in advance for your help

4229 Posts
Kadministrator
8 years ago
3
Level 3

In the code pack js plugin set Behaviour to Raw

8 years ago
2
Level 4

Behaviour is set to raw:

Free button parameter:

Line into page code:

input type="submit" id="btncontrolsomme" name="btncontrolsomme" value="btncontrolsomme" onclick="document.location.href='#'"

I think that the function name should be into a parameter of Free button, I have tried lot of possibility without success.

4229 Posts
Kadministrator
8 years ago
1
Level 5

Your problem is in your "custom" Link setting which overwrites js field bellow, set it to --Select--, then you should get your onclick attribute output correctly

8 years ago
0
Level 6

Hi,

  It's Ok now

Thank you very much

Get a VIP membership