Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

247
Vistas
How do I make it so when my array includes a specific word a text input shows up?

After getting help countless times in this forum, I finally created my own account after getting stuck in my code, and not being able to resolve it :(

Pre-info, I wanted to create a text adventure with javascript and followed this guide on youtube: https://www.youtube.com/watch?v=R1S_NhKkvGA&ab_channel=WebDevSimplified

I wanted my game to have several "rooms" that you can go thru, and some rooms you only can go thru if you have found a key for example. See demo. To do this i added if/if else at the end of my selectChoice.

However, If you watch the demo, I want so that when you press the button that says 'Go to Bowser's door(!!!)', a text input shows up, instead of the button that says Enter favorite song. The user is then supposed to enter a guess of Bowsers favorite song and if it's right they go to the next textNode (the one that now appears after pressing 'Enter favorite song'. If it's wrong I want a new text to show up and the option to go back to the previous room/textNode.

TLDR; I want it so that when i have a specific word in my array such as showInput: '(text that shows up on a label before text input)', a text input shows up for the user. Where if the user enters the right answer, the user gets sent to the next "id" in my array. See demo to visualise.

In conclusion, I cant seem to find the solution to implementing this function. Some help would be super appreciated.

If I missed any important information or have to explain my code, just let me know! This is my first post on stackoverflow :)

Here's the demo so far: https://willen17.github.io/Textspel/ Here's my files and code: https://github.com/Willen17/Textspel

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is an open ended question, but I'll try and help out. There are a few options for you, you can:

  1. create an <input /> tag and grab data from it (you'll probably want to use a form with something like onsubmit or a key listener) https://developer.mozilla.org/en-US/docs/Learn/Forms

  2. you can show a pop up called a prompt that asks the user for input. https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda