Search Support
-
Jairo FiorentinoNovember 2, 2018 at 1:33 pm #5323
Hi,
I have a coach, where there is a CustomHTML control which contains a script tag and a javascript function defined.
How I can call that function from a button defined in the same coach screen? That is, how to configure the button “on click” event to call the javascript function.
Thanks, Jairo
SPARK SupportNovember 6, 2018 at 1:30 pm #5333Hi Jairo,
You should be able to call the function from the On Click event, such as
myAlert();
which calls:
Regards,
Stephen P.
Jairo FiorentinoNovember 6, 2018 at 1:57 pm #5336Hi Stephen, Thanks for your response. I'm trying the way you described. I have a Coach with 2 controls ** CustomHTML ** Button CustomHTML code is: <h3>Generate Random</h3> <script> function generateRandom() { var val = Math.floor(Math.random() * 100); // debugger statement debugger; Alert(“New value is “ + val); //# sourceURL=neil.js }; </script> Button On-click event: generateRandom(); The response I get on the browser debug screen is that generateRandom() function is not defined. There is an article that suggest it must be called as @generateRandom() but I think that worked for a previous version See the attached file. Thanks, Jairo
SPARK SupportNovember 7, 2018 at 8:19 am #5338Hi Jairo,
There were two error in your script that once corrected executed correctly.
First, alert() is case sensitive and should not be capitalized.
Second, your quotes for “New value is ” need to be straight quotes, and not curly quotes like “ and ” .
Regards,
Stephen P.
Jairo FiorentinoNovember 7, 2018 at 9:08 am #5339Hi Stephen,
Thank you so much, that solved the problem … great 🙂
Thanks, Jairo
-
|
You must be logged in to reply to this topic.