6 Posts
Julie
4 years ago
1
Topic

In my form, I would like a button to run a javascript function (for starters, alert("Hi!"); ) that is stored in the form. How do I do this? Can you provide an example? I cannot get the most simplest thing to work. I work in a provide intranet and cannot give you access to my site.

I created a button field and a JS field.


In the free button field custom attributes - added onclick="testing();"

In the JS field, RAW,

function testing()

alert("Hi There!");

}

When I test this form, and press the button, I get an error -  "testing is not a function".

How do you add a JS function that the button onclick code will find and execute?

Get a VIP membership
6 Posts
Julie
4 years ago
0
Level 1

I figured out how to do it. I have a free button with a custom link. When I click on the plus sign next to custom, and a popup window opens, I added my function call in the Javascript field, testing();, saved and closed this field. Then I created a Javascript field - type, "script (JS)", added it to the hidden position in the form layout, when I edit the field, I set behavior "Raw", in the JS field, added the testing function: 

function testing()

{

alert("Hi There!");

}

Saved and closed the field, saved the form. These fields were under the Site tab. I opened the form in the front end browser, clicked on the button, and it displayed the alert window. It found the function and ran it.

Get a Book for SEBLOD