Basic JavaScript Learning

Hi Guys,

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

It’s really hard guessing what you are trying to do without a project file… :thinking:

1 Like

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:

Hope this helps

1 Like

Hi Rick,

It is a very simple function, just to understand how javascript and hype integrate with eachother.

https://we.tl/t-3lGOOKGBVV
The javascript button should count the number of clicks.

Cheers,

Joao

Hi Max,
I am taking a course in Javascript, the thing is I don’t quite understand hoe they integrate with each other.

I am new to this, so be patient, maybe in the future things will get easier.

Thanks,

Joao

if you want to place code to the headsection and have access to hypes API:

https://tumult.com/hype/documentation/3.0/#invoking-api-from-outside-oftumult-hype

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.

Cheers,

Joao

read a bit deeper … about Hypes Events and then following an example : https://tumult.com/hype/documentation/3.0/#events

1 Like

Joao,

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.

1 Like

GOT IT!
Thanks!