Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda