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

189
Views
Activar TextBox si se selecciona otra opción en PHP

Tengo dos listas desplegables y quiero, por ejemplo, si value=fetch seleccionado, mostrar el segundo menú desplegable pero no funciona.

Lo intenté con llamar a un archivo PHP externo pero me quedé atascado nuevamente. Creo que el problema es cuando llamo al método de cambio pero no sé qué escribir.

 function action(dropdown) { var value = dropdown.options[dropdown.selectedIndex].value; if (value == 'Fetch'){ document.getElementById("student_list").style.display = "block"; document.getElementById("subject_list").style.display = "none"; } if(value == 'Count'){ document.getElementById("student_list").style.display = "block"; } if(value == 'Percentage'){ document.getElementById("subject_list").style.display = "block"; } } <body> <div class="main_container"> <form method="post"> <select name="action" id ="fetch" onchange="action(this.value);"> <option value="" id="action">--Select Action--</option> <option value="Fetch">Fetch</option> <option value="Count">Count</option> <option value="Percentage">Percentage</option> </select> <select name="student_name" id ="student_list" onChange="" style="display:none;"> <!--onchange="getNext(this.value);" --> <option value="">--Select Action --</option> <option value="All">All Students</option> <option value="NameS">Student Name</option> </select> </form> </div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No puede usar una función llamada " acción ", consulte https://stackoverflow.com/a/37590405/5391965

Debe recuperar sus valores dentro de la función en lugar de pasarlos en parámetros como este:

 function displayStudentList(dropdown) { let subject = document.getElementById("subject_list").value; if (subject === 'Fetch') { document.getElementById("student_list").style.display = "block"; document.getElementById("subject_list").style.display = "none"; } if (subject === 'Count') { document.getElementById("student_list").style.display = "block"; } if (subject === 'Percentage') { document.getElementById("subject_list").style.display = "block"; } }
 <div class="main_container"> <form method="post"> <select name="action" id="subject_list" onchange="displayStudentList()"> <option value="" id="action">--Select Action--</option> <option value="Fetch">Fetch</option> <option value="Count">Count</option> <option value="Percentage">Percentage</option> </select> <select name="student_name" id ="student_list" onChange="" style="display:none;"> <!--onchange="getNext(this.value);" --> <option value="">--Select Action --</option> <option value="All">All Students</option> <option value="NameS">Student Name</option> </select> </form> </div>

about 4 years ago · Juan Pablo Isaza Report
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!