I am trying to do my first JavaScript trial. I am trying to do something very simple as to include a function in HTML’s head to listen to a button’s click, add that count to a variable and console.log this variable.
Just to see the start of interaction, but I can’t make it work.
Any help will be much appreciated.
Thanks,
Joao
Here is a general guide to start Javascript and CSS
After that the forum has plenty of examples and project files with code to load and examine using Javascript. Just search for the topic you are interested in.
Then you will find all the hypeDocument specific API functions in the documentation here:
Hi Hans, I read it but didn’t quite understood it. I have to export the document in order to know the document’s name then go back to hype to call it from hype’s html head?
I just would like to see it work once to understand how to call it and interact with it.
you can attach hype projects directly to your reply using the upload button in the toolbar at the top of your message.
You had your code in a function called myCallback which was in the HeadHTML. However, in the Actions inspector, you had set a click to run untitledFunction() which is empty.
You need to move only the code inside myCallback (not the whole myCallback function) into untitledFunction(). Once you do that, it will work provided you add quotes around your ID like this: ("Contador"). If you don’t add quotes, the code will look for a variable named Contador which, of course, does not exist. IDs are strings, not variables.
If I were you, I would look at the documentation that the others have linked to because you have to learn a little bit more about the basics to understand what you’re trying to do here.