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

193
Views
Cómo imprimir el valor seleccionado de una sola opción del menú de lista desplegable html

Hola, tengo este menú de lista desplegable y quiero hacer un script que cuando seleccione solo la última opción, las etiquetas cambien en html. Este es mi código que he hecho hasta ahora:

 <select id='type' name='type' class="form-control" onchange="loadText(this)"> <option value="S">S</option> <option value="B">B</option> <option value="F">F</option> </select> <script> function loadText(select) { alert(select.options[select.valueOf(2)].text); } </script>

Intenté obtener el valor de la opción seleccionada pero no funciona, antes de tenerlo

select.selectedIndex

pero quiero que esta función funcione solo para el último valor, no para los 3

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

<select id='type' name='type' class="form-control" onchange="loadText(this)"> <option value="S">S</option> <option value="B">B</option> <option value="F">F</option> </select> <script> function loadText(select) { var select = document.getElementById('type'); var lastValue = select.options[select.options.length - 1].value; var selectedValue = select.options[select.selectedIndex].text; if (lastValue === selectedValue) { alert(selectedValue); } } </script>
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!