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

178
Views
Mostrar una entrada según el valor de una lista desplegable Symfony

estoy tratando de mostrar una entrada de acuerdo con el valor de una lista desplegable con Symfony

mi cuadro de selección

 ->add('specialite', ChoiceType::class, [ 'attr' => ['class' => 'form-control mb-3'], 'label' => 'Speciality', 'choices' => array( 'Select' => null, 'Nurses' => 'nurses', 'Doctors' => 'Doctors', 'Engineers' => 'Engineers', 'IT-Specialist' => 'IT-Specialist', 'Anesthetist technicians' => 'Anesthetist technicians', 'Others' => 'Others', ), 'choice_attr' => [ 'Select' => ['disabled'=>'disabled'], ] ])

cuando el usuario selecciona otros, se le muestra otro campo, también estoy intentando con este código

tipo de formulario

 ->add('otherspec', TextType::class, [ 'attr' => ['class' => 'form-control mb-3'], 'label' => null, ])

html.ramita

 <script> let foo = document.getElementById("emplopyer_specialite"); let bar = document.getElementById("emplopyer_otherspec"); foo.addEventListener('change', (event) => { if (event.target.value === 'Others') { bar.style.display = 'none'; // Hide the element. } else { bar.style.display = 'inline'; // Show the element. } }); </script>

Mi problema, mi problema es cuando selecciono cualquier valor del cuadro de selección, aparece el segundo campo, sin embargo, quiero que aparezca cuando selecciono el valor = "otro"

Gracias

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!