Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
¿Cómo puedo hacer un formulario de selección html que luego haga más preguntas según la respuesta del usuario?

Soy un programador principiante de JavaScript que intenta crear un formulario de recopilación de datos html con JavaScript.

Mi objetivo es…

  1. preguntar al usuario por su edad y sexo,
  2. luego, si son menores de 18 años, pregúnteles cuál es su materia escolar favorita,
  3. si tienen entre 18 y 60 años pregúnteles su profesión,
  4. si tienen más de 60 años, si todavía funcionan.

No estoy seguro luego de hacer la pregunta de la edad inicial, de cómo solo hacer ciertas preguntas dependiendo de la respuesta del usuario a esta primera.

Aquí está mi código:

 <html> <head> </head> <body> <form> <label for="age">Select your age</label> <select id="age"> <option value="0">Under 18</option> <option value="1">18-60</option> <option value="2">60+</option> </select> <button id="next">Next Question</button> <!--<select id="subject"> <option value="0">Math</option> <option value="1">English</option> <option value="2">Science</option> <option value="3">History</option> <option value="4">Geography</option> <option value="5">Technology</option> <option value="6">Art</option> <option value="7">PE</option> <option value="8">Other</option> </select> </form--> <script> const next = document.querySelector('#next'); const sb = document.querySelector('#age') next.onclick = (event) => { event.preventDefault(); // show the selected index alert(sb.selectedIndex); }; //if (sb.selectedIndex == 0) { //} </script> </body> </html>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!