RichardGolko
Posts: 0
Joined: Thu Oct 25, 2012 11:25 pm

How Do I Call a Javascript function in a Javascript file?

I added a new javascript (create drop down) and put the following function in it:

function(addNumbers){
return 1+1;
}

I called the javascript object "addNumbers' without the quotes.

In a button on a screen I added a click handler and selected Run Custom JavaScript; I put the following for the javaScript:

var x = addNumbers();
alert(x);

But when I test and press the button nothing happens.

How do I call my custom function?

Also if I put 'alert' in the function, will that work (once I know how to call the function?)

Thanks.

RichardGolko
Posts: 0
Joined: Thu Oct 25, 2012 11:25 pm

How Do I Call a Javascript function in a Javascript file?

Never mind; It would help if I wrote the function correctly:
function addNumbers() {
return 1+1;
}

And yes, alerts can be included in the javascript functions.

jimmy vu
Posts: 0
Joined: Thu Apr 04, 2013 10:26 am

How Do I Call a Javascript function in a Javascript file?

this didn't work

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

How Do I Call a Javascript function in a Javascript file?

Hello,

It's works. Plese try to create a simple App: add button to screen and put JS code on button click event.

code
function addNumbers() {
return 1+1;
}
alert(addNumbers());
/code

Return to “Issues”