How to display text in different scene?

I have 2 scenes, where the first one displays the input textbox and the submit button. So when i type in the text, and click submit, it will go straight to the next scene, and there, it displays the text I’ve typed.

i have tried inputting the hypeDocument.getElementById().value / innerHTML in the javascript section.
But the submit button need to submit the value AND go to the next scene. I cannot achieve this part.

may i know how to code this thing properly? The submit button would not go to the next scene even i have put it under Mouse Click.

Put this script in the “On Scene Load” option of the Scene Inspector of Scene 2. The input field in Scene 1 needs an id of ‘name’ and the next scene needs a text box with an id of ‘fromS1’.

var txt1 = hypeDocument.getElementById('name').value; //gets from scene 1
  
hypeDocument.getElementById('fromS1').innerHTML = txt1;  //puts in scene 2

PS: I am not using a form ‘Submit’ button, just a standard Hype button to go to the next scene.

1 Like

Hi!

Thanks for the reply. I tried the codes you have shown me.

But somehow, when i go to the next frame, it shows Undefined.

may i know those 2 codes above put within the javascript function?

Did you assign an Id of 'name' to the input box in the innerHTML?

<input type="text" id="name" name="enter" value="">

an example sometimes helps :wink: this is what Greg was saying

displayTextDifferentScene.zip (23.5 KB)

2 Likes

Hi!!
Thanks for the example. It works now. Thank you to both of you :smiley:

1 Like

I habe a Project, where it is necessary, that the input-field in the first scene hold his value. How can it work. The project will`ve more then 10 scenes. And all scenes have input-fields. And the user can switch from scene to scene. If the fields lost there value, the project will be crashed. Have you a simple solution?

Would using a “class” instead of an “id” work, then set your input box as a persistent symbol?

<input type="text" class="name" name="enter" value="">

You save my day and my project. Thank you so much. Your idea brings the solution for me. But not exactly in this way. My input-field look like that:
input type=text" id=“name” value=""
Then, in the next step, i set the input-field as a persistent symbol with the choice “add to the current scene”.

name2scene.zip (26.3 KB)

2 Likes