How to use a button to change text

Need a lot of help :frowning: I’m a first time user, I know a little about coding but not really how to implement it into Tumult Hype.

I’m trying to figure out when clicking a button, it changes the text in another area. The user will be clicking different objects/buttons that will change the text repeatedly. Should I be using symbols for this?

Another question would be if the user clicks on the wrong button/object), the text should not change, but maybe display an error? (i.e. turn red) and the button should not disappear.

Basically the user must find correct objects according to the text.

There are plenty of examples of this on the site, maybe a search for quiz or/and innerHTML


Basically here are the steps

1 give an id to each of your text containers (last panel of the inspector)
2 create a script for each of your buttons : in the asset panel clic + and choose javascript fonction.
the javascript should be something like that:
hypeDocument.getElementById(‘myTextContainer’).innerHTML='my text’
where myTextContainer is the id of your text box to be set
3 select your button and attached the relevant script on it via the action panel of the inspector

Thanks all for the advice. I figured out how to do this using symbols and custom behaviors. Which has worked beautifully, but now I can’t figure out how to control these behaviors where they happen only when one is first triggered… i.e. the user must click on the tomato before he can click on the pen… right now, the behaviors make everything free game if you click on the object, even if the user hasnt been prompted yet. If that makes any sense!


Provided one possible solution in your other post:

Thank you! It worked!! :smiley: